Mod_rewrite

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Mod_rewrite

Postby BBone1 » 18. June 2014 02:46

I have xampp lite 1.8.3
I would like to enable mod_rewrite and for a start in xampp/apache/conf /httpd.conf the line LoadModule rewrite_modules/mod_rewrite.so is uncommented already. Searching I found to uncomment and to and to have all AllowOverride All.
So in Server name localhost:80 and the following directory changed to All. The next directory <Directory "C:/xampp/htdocs"> it already has
Options Indexes FollowSymLinks Includes ExeCig
AllowOverride All and Require all granted. The next directory <Directory "C:/xampp/Cgi_bin"> All and Require granted.
When I load phpinfo() on the server it doesn't show in the loaded modules list, Mod_rewrite as loaded in that list.
With the apache documentation it says recomemded to put rewrite Rule etc in VirtualHost block and I'd like to do that, to get used to it etc.
In xampp/apache/conf/extra/httpd-vhost.conf it has examples for two sites using one host.
Searching I found using two blocks for such as www.example.com and www.example.org which is what is explained in the vhost file.
Also searching to set up vhost I found and assume for it to be so for one domane hostname.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot C:/xampp/htdocs
SeverName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExeCig
AllowOverride All
Order allow deny
Allow from all
</Directory>
Then I assume
<IfModule mod_rewrite.c>
Rewrite Engine On
etc for the condition and rules
</IfModule>
Thanks for your advice and I hope I don't seem a dummy.
Could you tell me if I'm on the right path in setting it up and if the rewrite module is loaded. Does the file in xampp/apache/cof/original/httpd.conf have any bearing as it is the same as the other except #LoadModule rewrite_module Modules/mod_rewrite.so is commented as I have here.
Thanks for your time
BBone1
BBBBB
BBone1
 
Posts: 3
Joined: 31. July 2013 20:04
Operating System: windows 8

Re: Mod_rewrite

Postby Altrea » 18. June 2014 05:28

BBone1 wrote:Searching I found to uncomment and to and to have all AllowOverride All.

Sorry, but thats not good practice. Set AllowOverride to exactly this value you need and only at the places you need that.

BBone1 wrote:So in Server name localhost:80 and the following directory changed to All.

Undo your changes expecially for the Block <Directory />

BBone1 wrote:With the apache documentation it says recomemded to put rewrite Rule etc in VirtualHost block and I'd like to do that, to get used to it etc.

You don't need that.
rewrites are strictly application dependend so i would define them as near to your application as possible (in an .htaccess file inside the root directory of your application).

BBone1 wrote:Also searching to set up vhost I found and assume for it to be so for one domane hostname.
Code: Select all
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot C:/xampp/htdocs
    SeverName localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
    <Directory "C:/xampp/htdocs">
        Options Indexes FollowSymLinks Includes ExeCig
        AllowOverride All
        Order allow deny
        Allow from all
    </Directory>


Use code-BBTags at this board here to make your code more readable.

Your vhost definition is incorrect:
  • At the end is a </VirtualHost> missing
  • There is a comma missing between allow deny
Two more hints:
  • Order, Allow from and Deny from are old access syntax. Use the new one
  • htdocs is already configured by an Directory Block in your httpd.conf, no need to do that in your vhost again.

BBone1 wrote:Could you tell me if I'm on the right path in setting it up and if the rewrite module is loaded.

Whether or not the rewrite module is loaded for your request nobody can say this except you.
By default mod_rewrite is activated in XAMPP.
As already said i would use an .htaccess file for it.

BBone1 wrote:Does the file in xampp/apache/cof/original/httpd.conf have any bearing

No file inside xampp/apache/conf/original/ is important, that are only templates.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8290
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 66 guests