How can I rewrite to my .htaccess in PHP? [duplicate]

How can I rewrite to my .htaccess in PHP? [duplicate] - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about php, htaccess, url, mod-rewrite, .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :






How to rewrite my URL from http://www.mysite.com/listingsecond.php?ID=1 to http://www.mysite.com/listingsecond?



How can I rewrite to my .htaccess in PHP to do this?


Solution :

On your PHP file, use the $_GET variable to process the query as you need, then when generating the response, redirect to the address that you want using the header function. Specifically, the location attribute


Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect