SEF Urls, avoiding multiple choices error when trying to access the redirect folder

13 views Asked by At

I have setup SEF URLs via htaccess on my site to rewrite the urls for the blog so that any request like this:

https://example.com/blog/slug

show the content from this:

https://example.com/blogsearch.php?slug=?

It all works fine however if I go to the URL:

https://example.com/blog/

I get the multiple choices error, how can I make it so I can go to that URL and show a unique page without the error?

I don't mind if it shows the content from either a separate page blog.php or shows the content from blogsearch.php as if the slug parameter had been left blank, just as long as the user can access the page on the URL https://example.com/blog/ without an error

Heres the relevant parts of my htaccess file:

## set strickt transport policy to force https
<IfModule mod_headers.c>
     Header always set Strict-Transport-Security "max-age=16070400"
</IfModule>


######################## add this to fix variable issue
Options -MultiViews +FollowSymLinks

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

RewriteBase /
RewriteCond %{HTTP_HOST} !^example.com$ [NC]  
RewriteRule .? https://example.com%{REQUEST_URI} [R=301]

RewriteRule ^blog/([a-zA-Z0-9.\-_]+) blogsearch.php?slug=$1 [QSA]

</IfModule>```
1

There are 1 answers

0
user3914769 On

Good old AI showed me the way, I just needed to add a rewrite rule for the /blog/ part before the existing rule:

RewriteRule ^blog/$ blog.php [L]
RewriteRule ^blog/([a-zA-Z0-9.\-_]+) blogsearch.php?slug=$1 [QSA]