Forum Moderators: phranque
RewriteRule ^p([0-9]+)-(.*).html$ script.php?p=$1 [L]
Will pass the data from this url:
[domain.com...]
to the following script as such:
[domain.com...]
But I'd like to do the same thing with text. Something like:
RewriteRule ^u([0-9]+).html$ username.php?u=$1 [L]
Where a call to [domain.com...]
would call
[domain.com...]
Is this possible? I assume that [0-9] means numbers only. So how would you make it pass only letters and numbers and no special characters?
RewriteRule ^u([a-z0-9]+)\.html$ /username.php?u=$1 [NC,L]
RewriteRule ^u([A-Za-z0-9]+)\.html$ /username.php?u=$1 [L]
I hope I understood your question...
Note that the periods in your patterns need to be escaped as shown.
See the references in our forum charter for a nice regular epressions tutorial.
Jim
Options FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.html$ /mypage\.php?addition2=$1 [NC,L]
RewriteRule ^(.*)\.html$ /my-other-page\.php?addition3=$1 [NC,L]
RewriteRule ^index\.html$ /index\.php [NC,L]
It reads the first rewrite Rule but not the following ones. Any hint?
I also tried the same htaccess with [L] instead of [NC,L]
No success
You need to decide what you want your rules to do. Your first rule will always match anything the next two might match, so as a result, the first rule will always run for any ".html" page request, and the next two will never run.
The regular-expressions patterns in your three rules must be designed to detect the cases where you desire to rewrite to the three different URLs.
Jim
The regular-expressions patterns in your three rules must be designed to detect the cases where you desire to rewrite to the three different URLs.
Could you give an example? I am not sure I understand why it would not recognize that the rewriting is for two different php urls:
1/ /home-furnishing\.php?addition2=$1
2/ /home-furnishing-article\.php?addition3=$1
I tried to for example make 2/ as :
RewriteRule ^another-folder/(.*)\.html$ /home-furnishing-article\.php?addition3=$1
but it is not doing anything. I think I am missing the point. If you could provide an example if you dramatically help I think.
Thanks
The first entry following RewriteRule is the URL requested by the client browser. The second entry is the location on the content you want to server when that first URL is requested:
RewriteRule [i]requested_URL[/i] [i]new_URL[/i]
Please see the references cited in our charter [webmasterworld.com].
Jim