简体   繁体   中英

how to write multiple rewrite rule in single htaccess file?

I am creating a blog website in which there are 6 pages index.php, about.php, contact.php, blog.php, event.php, and news.php. I want to remove.php extension from the url and write seo frendly url.

from blog.php single blog are showing on page blogpost.php. from event.php single event are showing on page eventpost.php. from news.php single news are showing on page newspost.php.

My problem is only first rewriterule is working.

how to write multiple rewrite rule in a single.htaccess file.

Here is my.htaccess file code

Options -MultiViews

RewriteEngine On

RewriteRule ^([^/\.]+)/([^/\.]+)?$ eventpost.php?event_slug=$2
RewriteRule ^([^/\.]+)/([^/\.]+)?$ post.php?title_slug=$3
RewriteCond %{REQUEST_URI} !\.php$ [NC]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} [^/]$

RewriteRule ^(.*)$ $1.php [L]

try this

Options -MultiViews
RewriteEngine on

RewriteBase /

RewriteRule ^([^/\.]+)/([^/\.]+)?$ eventpost.php?event_slug=$2
RewriteRule ^([^/\.]+)/([^/\.]+)?$ post.php?title_slug=$3
RewriteCond %{REQUEST_URI} !\.php$ [NC]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} [^/]$
RewriteRule ^(.*)$ $1.php [L]

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