Ad

Rewrite URL For Blog-detail.php/{slug} Into Blog-detail/{slug}

i have successfully rewrite www.my-website/blog.php into just www.my-website/blog

Now, i want to do further things to my blog-detail.php page from www.my-website/blog-detail.php/how-seo-works into www.my-website/blog-detail/how-seo-works

'how-seo-works' is my slug and it can be anything depends on article's title

When i tried the www.my-website/blog-detail/how-seo-works the error is Internal Server Error

Here's my htaccess:

# Run Php without filename extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

# Return 404 if original request is .php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]

the error appears in website:

Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

in Error logs: AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://localhost:8080/my-website/blog

Ad

Answer

I have solved this problem.

So, here's my modified .htaccess to access my-website/blog-detail/how-seo-work

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^blog-detail/([0-9a-zA-Z-]+) blog-detail.php?id=$1 [L,QSA]

RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
Ad
source: stackoverflow.com
Ad