Reputation: 69
So I have a Rewrite in my .htaccess that works correctly with what I originally planned.
RewriteEngine on
RewriteRule ^([^/]+)/?$ index.php?id=$1 [QSA]
I have index.php?id=4 going to /4/.
The Problem
If I try to go to another page though, it always brings me back to index.php. For example, I have a page called "Update.php". If I go to update.php, I'm redirected to index.php
Any suggestions?
Thanks in advance,
Upvotes: 0
Views: 47
Reputation:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f #check if requested file not found
RewriteCond %{REQUEST_FILENAME} !-d #check if requested directory not found
RewriteRule ^([^/]+)/?$ index.php?id=$1 [QSA] #then apply the rule
The above rule first checks if requested URI not a real file and folder, then applying the rule, this prevents to redirect when opening existing file and folder.
Upvotes: 1
Reputation: 18568
Add this line
RewriteCond %{REQUEST_FILENAME} !-f
Above your rule
This only rewrites when the file doesn't exist
Upvotes: 1