Welcome to PHP Smarty Q&A, where you can ask programmaing questions and receive answers from other members of the community for PHP, Smarty, MYSQL related. You can also share or save your scripts in this repository for future reference.
Bulk SMS Marketing

htaccess rules not working in xampp

+1 vote
108 views

I am working on php project where I have written few rewrite rules for my urls which does not work in my xampp.

My .htaccess code is

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^terms$ terms.php
RewriteRule ^faq$ faq.php
</IfModule>

And I hosted this project in htdocs as myfirstphp and .htaccess is within that folder.

Where am I going wrong or what else I need to do? Kindly suggest.

Thanks in advance.

asked Oct 6, 2015 in PHP by javed

1 Answer

0 votes

On your server, public_html / www folder acts as your root folder, and in xampp, it is htdocs.

So you basically, write htaccess rules in your root folder and you upload that folder to a sub-folder in htdocs as myfirstphp, so you need to RewriteBase as /myfirstphp/

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myfirstphp/

RewriteRule ^terms$ terms.php
RewriteRule ^faq$ faq.php
</IfModule>


This should get you going.

answered Oct 6, 2015 by robert (13,210 points)
...