简体   繁体   中英

.htaccess url to post by slug

I have blog with posts. When i click on read more button i want to redirect and show selected post. Wanted url is http://www.solutions.com/blog/blog-post/slug .

In .htaccess i have this:

RewriteEngine on RewriteCond %{HTTP_HOST} ^solutions\.com 
RewriteRule ^(.*)$ http://www.solutions.com/$1 [R=permanent,L]
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}
!-f RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^(.*)$ 
$1.html [L]

RewriteCond %{REQUEST_FILENAME} !-d RewriteCond
%{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php

RewriteBase / RewriteRule ^blog/blog-post/(.+)
blog/blog-post.php?slug=$1

But I get an error:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

How can I solve this?

Would the PLUS sign in the last line be causing the problem?

So instead of:

RewriteRule ^blog/blog-post/(.+) blog/blog-post.php?slug=$1

try

RewriteRule ^blog/blog-post/(.*) blog/blog-post.php?slug=$1

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