Problem With Mod_Rewrite

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
leebo
Forum Commoner
Posts: 44
Joined: Sun Oct 20, 2002 9:49 am

Problem With Mod_Rewrite

Post by leebo »

Hi

I'm having big trouble setting up my pages to use mod_rewrite.

In my .htaccess I have the following.

RewriteEngine On
RewriteRule /index/([0-9]+)/.html$ /index.php?ref=$1

I`m wanting index.php?ref=1029

look like

index/1029.html

Can anybody help me ?

Thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

first you need to quote the dot with a \ not a /
Then, if it is in your .htaccess of the document root, it already matched the <directory / > directive. Only the remaining path is taken into consideration.
so, if e.g. the url is http://my.serv.er/index/12345.html only index/12345.html 'reaches' the rewrite rule.
try

Code: Select all

RewriteRule ^index/(&#1111;0-9]+)\.html$ /index.php?ref=$1
instead.


Also note that you must have override privileges for FileInfo in order to create a new rewrite rule
leebo
Forum Commoner
Posts: 44
Joined: Sun Oct 20, 2002 9:49 am

Post by leebo »

Hi

Thanks for that I have got it working at last using the following code:

RewriteEngine On
RewriteRule ^(.*)\.html$ /page.php?page_name=$1

so...

so the link page1.html would be the same as page.php?page_name=page1

That works fine but have now got another problem

another link on my site like home.html or links.html does page.php?page_name=home etc...

How can I have some html links goto to the rewrite and some not ?
Post Reply