Abuda Dumiaty
Abuda Dumiaty

Reputation: 317

need .htaccess RewriteRule advise

I've looked around for an answer to this, no luck.

What i want to do is replace

http://localhost/mysite/superv/something with

http://localhost/mysite/superv/?p=something

Here's the best formula I came up with since yesterday:

RewriteEngine On
RewriteBase /mysite/
RewriteRule ^(superv/)([^\?/]+)$ $1\?p=$2 [NC]

Yet it's not working.

I think the "RewriteBase" thingy has nothing to do with the problem because this line is working like a charm:

RewriteRule ^(javascripts/main\.js)$ $1\.php [NC]

Edit: Right Rekire, that was a mistake while copying and pasting the code. I've fixed the question now.

Edit2: Here's the error that appears in apache logs:

 [Tue Mar 20 20:26:01 2012] [error] [client 127.0.0.1] 
 Request exceeded the limit of 10 internal redirects due to probable configuration error.
 Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

I'm guessing the problem is "looping" and I quote:

 Looping occurs when the target of a rewrite rule matches the pattern. 
 This results in an infinite loop of rewrites

Upvotes: 0

Views: 406

Answers (2)

Abuda Dumiaty
Abuda Dumiaty

Reputation: 317

For some reason, this formula worked (internal redirect):

RewriteRule (.*)(superv/)?(.*) $1$2index.php?p=$3 [NC,QSA]

It seems to have broken the "infinite loop".

Upvotes: 1

AndrewR
AndrewR

Reputation: 6748

This appears to be working for me.

RewriteRule ^(superv/)([^\?/]+)$ $1?p=$2 [R,NC]

Remove the R, if you want to do an internal redirect.

Upvotes: 1

Related Questions