I have run into an issue with my .htaccess file.
The file changes the ugly URL such as http://localhost/news.php?article_slug=example-1 to http://localhost/news/example-1
This works perfectly, but when I go to http://localhost/news i get a 404 error.
Within news.php I have a redirect; so if there is not an article slug in the URL it will redirect to latest.php.
my PHP code on news.php
$article_slug=$_GET['article_slug']; if (empty($_GET)) { header("Location: ../latest.php"); die();// no data passed by get } This is what I currently have in my .htaccsess file
Options -MultiViews RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} 200 RewriteRule ^ - [L] RewriteRule ^news/([\w\d-]+)$ /news.php?article_slug=$1[QSA,L] RewriteCond %{QUERY_STRING} article_slug=([\w\d-]+) RewriteRule ^news$ /news/%1 [R,L] RewriteRule ^category/([\w-]+)$ /category.php?category_slug=$1&page=$2 [QSA] When I try to debug this myself (with very little knowledge) and add the following line it redirects to latest.php
RewriteRule ^([^/]*)/?$ /news.php [L,QSA] but on the redirected page I get the following error
The page isn’t redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies When I use the developer tools in firefox as IMSoP commented all I see is latest.php reloaded multiple times.
This is not just isolated to just latest.php but any file on the server thats not listed in the access file
when I remove the line
RewriteRule ^([^/]*)/?$ /news.php [L,QSA] I can load the PHP file but it doesn't redirect from news.php and http://localhost/news is not found but http://localhost/news/example-1 works.