I have 1 page
https://domainsanalytics.com/country.php
I am passing values like
https://domainsanalytics.com/country.php?id=219
I want to make SEO friendly URLs like
https://domainsanalytics.com/country/219
That I try to accomplish by this
RewriteRule ^(country)/(\d+)/?$ $1.php?id=$2 [L]
But that gives me a bug on my pages, example: https://domainsanalytics.com/country/219
If i add before the above code,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
That work for
https://domainsanalytics.com/country
but 404 on
https://domainsanalytics.com/country/219
I need help to make sure both work well
https://domainsanalytics.com/country/219
and
https://domainsanalytics.com/country
PS : When you open website htaccess has only
RewriteRule ^(country)/(\d+)/?$ $1.php?id=$2 [L]
RewriteRule ^(tld)/(\d+)/?$ $1.php?id=$2 [L]
RewriteRule ^(registrar)/(\d+)/?$ $1.php?id=$2 [L]
and screenshot
EDIT
RewriteEngine ON
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(country)/(\d+)/?$ $1.php?id=$2 [L]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(tld)/(\d+)/?$ $1.php?id=$2 [L]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(registrar)/(\d+)/?$ $1.php?id=$2 [L]
That work...
With your shown samples, could you please try following. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(tld|registrar|country)/(\d+)/?$ $1.php?id=$2 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^/]*)/([^/]*)/?$ $1.php?id=$2 [QSA,NC,L]
JS/CS rewrite/redirect:
You may need to use base tag to fix your js and other relative resources. If you are linking js files using a relative path then the file will obviously get a 404 because its looking for URL path. for example if the URL path is /file/ instead of file.html then your relative resources are loading from /file/ which is not a directory but rewritten html file. To fix this make your links absolute or use base tag. In the header of your webpage add this <base href="/">
so that your relative links can load from the correct location.