Why is My .HTACCESS Code Not Rewriting the Title Tag?

30 Views Asked by At

On my website, whenever there is: photo?title=SOME-URL I want to change it with photo/SOME-URL

For example, check the bottom-left corner of this image:

enter image description here

Even though I'm redirecting internally and externally, it still does not work.

The external redirect is giving me a 500 Internal Server Error.

What am I missing?

I have this in my .htaccess: Note: (domain name replaced with example)

Options +FollowSymLinks -MultiViews

# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# This sets my public folder as main directory
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ public/index.php [L]

# To remove the query title and introduce looks
RewriteCond %{THE_REQUEST} \s/+photo(?:\.php)?\?title=([A-Za-z0-9\-\_]+) [NC]
RewriteRule ^ photo/%1? [R,L]

RewriteRule ^photo/([A-Za-z0-9\-\_]+)/?$ photo.php?title=$1 [NC,L]

# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=302,L]

# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
0

There are 0 best solutions below