I have a website with this structre
index.php / home.php / profile.php / news.php / photos.php
newsfeed.php - for news article
photo.php - for photo
there is also username for users to get short link for his profile like
mysite.com/UserName
now I'm using this code in .htaccess to rewrite URLS of username
RewriteEngine on
RewriteOptions MaxRedirects=1
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
RewriteRule ^([^/]+)/?$ profile.php?u=$1 [L]
now I want to rewrite all my links to be SE-Friendly like this
index.php --> index
home.php --> home
photos.php --> photos
videos.php --> videos
newsfeed.php?id=xx --> news/xx
photo.php?id=xx --> photo/xx
So any idea ?
Here's what I'd do:
RewriteEngine on
RewriteOptions MaxRedirects=1
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
RewriteRule ^users/([^/]+)/?$ profile.php?u=$1 [L]
RewriteRule ^news/([0-9]+)/?$ newsfeed.php?id=$1 [L]
RewriteRule ^photo/([0-9]+)/?$ photo.php?id=$1 [L]
RewriteRule ^videos/?$ videos.php [L]
RewriteRule ^index/?$ index.php [L]
RewriteRule ^home/?$ home.php [L]
And just add them on like so.
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.