My HTACCESS file currently looks like this:
RewriteEngine On
RewriteBase /
# stop directory listings
#Options -Indexes
#stops htaccess views
#<Files .htaccess>
#order allow,deny
#deny from all
#</Files>
# redirect game folders
RewriteRule ^games/([^/]+)/([^/]+) games.php?author=$1&slug=$2 [L]
# redirect edit
RewriteRule ^protected/edit-game/([^/]+)/([^/]+) protected/edit-game.php?author=$1&slug=$2 [L]
RewriteRule ^admin/edit-game/([^/]+)/([^/]+) admin/edit-game.php?author=$1&slug=$2 [L]
# redirect view
RewriteRule ^protected/view-game/([^/]+)/([^/]+) protected/view-game.php?author=$1&slug=$2 [L]
# redirect user
RewriteRule ^page/([^/]+) user.php?user=$1 [L]
# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)/index$ $1/ [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
ErrorDocument 404 /error-404.php
I have a new requirement to make it so when someone goes www.domain.com/im-a-page-in-database
It goes to my page.php, grabs the hidden 'slug' -> 'im-a-page-in-database' and queries the database returning that specific page object.
Thing is, if I add into my HTACCESS file something like this:
# redirect pages/posts
RewriteRule ^([^/]+) page.php?slug=$1 [L]
It just overwrites all the previous rewrites that may be successful and displays my page.php regardless of where it is placed in the htaccess file?? I thought L meant if the rule was recognised... it should stop trying to do stuff. so if i put my new line under all my redirects, it should do the page check last.. but nope :(
Any ideas?
Maybe that's because of your 301-Redirect? The browser caches these redirects, so you'll have to try an other browser or clear your cache.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.