473,770 Members | 6,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regular expression mod_rewrite (htaccess)

I use htaccess to rewrite the url using the following rules :

RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$
index.php?lang= $1&page=$2&id=$ 3

The only problem I have is when http://www.domain.com/admin is given,
the "admin" is used as $1. How can I define the rule for every word
given except "admin" ?

Thanks in advance!

Oct 4 '05 #1
2 2845
"Geradeaus" wrote:
I use htaccess to rewrite the url using the following rules :

RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$
index.php?lang= $1&page=$2&id=$ 3

The only problem I have is when http://www.domain.com/admin is given,
the "admin" is used as $1. How can I define the rule for every word
given except "admin" ?

Thanks in advance!


Use a rewrite condition to exclude this case:
<http://httpd.apache.or g/docs/1.3/mod/mod_rewrite.htm l#RewriteCond>

Something like this perhaps:
RewriteCond %{REQUEST_URI} !^admin.*$
RewriteRule ...

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Oct 4 '05 #2
Thanks , that's what I needed :o)

Oct 4 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1894
by: kurt.krueckeberg | last post by:
I am considering going with the ISP Dreamhost because they offers both php4 and php5 support. However, I recently learned php4 runs as a regular CGI by default. This can be change, so it will runs as an Apache module. But if you want to run php5, you must run as PHP-CGI. Dreamhost states there are: "There are a FEW VERY MINOR drawbacks to running PHP-CGI. They are: * Custom 404 pages won't work for .php files with PHP-CGI.
11
2084
by: joelbyrd | last post by:
I have a people-networking type site in which each user has their own profile page, with their user id encoded. So, for example, the web address of their page might look like "www.example.com/my_profile.php?user_id=fdjkhfh2489298hf298h3s0dhfxj". I want the users to be able to choose their own web address that would look like "www.example.com/Joel", and then when they type in that address, they are automatically redirected to their profile...
3
1980
by: Rik G. | last post by:
I'm trying to replace a PHP query string with virtual directories using Apache's mod_rewrite. Here's my test .htaccess: RewriteEngine on RewriteRule ^qqq$ database.php?cat=0 RewriteRule ^qqq/xxx$ database.php?cat=0 The problem is that database.php contains several relative paths to images. This means mydomain/qqq works fine and all the images are found but when typing mydomain/qqq/xxx the file database.php seems to think it
4
2485
by: Hermann.Richter | last post by:
I want to rewrite URLs like http://domain/dir/file.php?var1=val1&var2=val2#anchor to http://domain/dir/file?var1=val1&var2=val2#anchor In other words, I want to strip out the php extension I tried putting in the .htaccess file the following:
5
4844
by: laredotornado | last post by:
Hi, I have verified that mod_rewrite is enabled on my Apache 2.2 instance. However, now I'm having a problem just serving pages using .htaccess files. Following Rik's advice, my .htaccess file is as follows RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} !^accesscontrol.php
0
1259
by: Ja NE | last post by:
I would like to offer my registered users to have very short uri for their pages in our comunity site, so I have enabled wildcard dns *.bellay.com. and added virtaul host for it. (I'm testing this on one domain I don't use so no harm will be done in testing time). and that is working. than I tried to write mod_rewite rule in .htaccess which should redirect anything.bellay.com to bellay.com/index.php?user=anything but I failed. ...
2
9256
by: jaanus | last post by:
Here we go... What I have been trying to do is to forward all http requests containing /cms/ to http://cms.mydomain.com/ example1: http://host1.mydomain.com/cms/init.php would be parsed from http://cms.mydomain.com/init.php (via ajax request) example2: <script src="http://host1.mydomain.com/cms/example.js" in <html><head> would be parsed from http://cms.mydomain.com/example.js physically there are no cms directories in...
3
1856
by: dennis.sprengers | last post by:
* I'm trying to work out some rewrite rules that should do the following: case 1: a request to mysite.com: rewrite http://www.mysite.com/files/sheets.ppt to http://www.mysite.com/sites/default/files/sheets.ppt case 1 - n: a request to othersite.com: rewrite http://www.othersite.com/files/sheets.ppt to http://www.othersite.com/sites/othersite/files/sheets.ppt
1
1889
by: macaco | last post by:
I'd like to redirect URLs in a directory in this way: categories/anything/index.php?id=13 to categories/index.php?id=13 To achieve that, I've uploaded a .htaccess file to "categories" directory that contains the following: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9869
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.