DomingoSL
DomingoSL

Reputation: 15504

Issue with mod_rewrite

this is my htaccess file:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*) url.php?p=$1 [NC]

Im trying to redirect like this: mysite.com/sometext to mysite.com/url.php?p=sometext

But with that file the browser gives me always an error; Internal Server Error, The server encountered an internal error or misconfiguration and was unable to complete your request.

Upvotes: 0

Views: 49

Answers (2)

souser
souser

Reputation: 6124

The following should work. The "L" ensures that it will be last rewrite rule, which should prevent the loop.

RewriteRule ^/(.*)$ https://mysite.com/url.php?p=$1 [NC,R,L]

This one might work too (will need to try it out)

RewriteRule ^/(.*)$ url.php?p=$1 [NC,L]

Upvotes: 0

Jon Lin
Jon Lin

Reputation: 143936

Try adding some conditions to keep mod_rewrite from looping internally forever:

RewriteCond %{REQUEST_URI} !^/url.php

Or:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Right before the RewriteRule

Upvotes: 1

Related Questions