Go easy on me I'm new to making changes to .htaccess files. I have the following .htaccess file:
RewriteEngine On RewriteBase / # Exclude rewriting for specific file types and existing files RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !\.(css|js|png|jpg|gif)$ # Redirections RewriteRule ^search$ search.php [L] RewriteRule ^our-story$ our-story.html [L] RewriteRule ^blog$ blog.php RewriteRule ^contact$ contact.html RewriteRule ^faq$ faq.html RewriteRule ^pricing$ pricing.html RewriteRule ^register$ register.php RewriteRule ^login$ login.php RewriteRule ^dashboard$ dashboard.php RewriteRule ^404$ 404.html # 404 Page ErrorDocument 404 /404.html The questions and problems are as followed.
- The 404 doesn't work when the 404 isn't in home directory example https://link.com/fakelink will go to 404 correctly but https://link.com/direct/fakelink will not go to 404 correctly.
- Is there a better way to handle Redirections without having to manually do each one like I am currently doing?
Another thing I don't know how to do I have a php file that looks like (https://link.com/list.php?url=city-location/listing-name) I want it to rewrite to https://link.com/city-location/listing-name how can I go about doing this?
All help is appreciate!
RewriteRule ^(search|blog|...)$ $1.php [L], and the same for the.htmlfiles.^search$rule only, and that does neither match an existing file, nor does it have any of those suffixes.RewriteRule ^404$ 404.html. Try and remove that. (There should be no real need to have a "pretty" URL for your error document, no one is expected to deliberately request/404in the first place, right?)