简体   繁体   中英

htaccess rewrite rule for redirecting and removing extensions

In my .htaccess file I have these rewrites

#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^([^\.]+)$ $1.php [NC,L]
 RewriteRule ^/admin/$ http://socialable.comuv/admin.php [R=301,L]
#noted out three lines since it's not what I need anymore I forgot the RewriteRule originally

Yet now it seems to not work at all, it keeps giving errors everywhere. I want is this

/admin/ (directory) to become /admin.php (file)
administration.php to become /administration

Try this:

RewriteRule ^admin/?$ admin.php [R,L]
RewriteRule ^administration\.php administration [R,L]

Once you are satisfied that the redirect works, you can change the R to R=301 to make it permanent.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM