RewriteBase in .htaccess is ignored

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

RewriteBase in .htaccess is ignored

Postby skunkbad » 17. May 2010 07:55

I'm a new XAMPP user. Switching from wampserver2, which I do like as well, but like XAMPPs built in SSL.

I use subdirectories of /htdocs/ for all of my websites, and there are many. I would like to be able to use a RewriteBase in an .htaccess for each site. Normally if the subdirectory holding a site is /example/, then I would simply add RewriteBase /example/ to my .htaccess file, but it is being ignored. It is as if AllowOverride is None, but I did set to All! I can change my rewrite rules to include the subdirectory, and then they work fine, but this is a nuisance. What can I do to the .conf files so that I can set it and forget it? I've had some basic Apache experience, but I can't figure out something like this.
skunkbad
 
Posts: 13
Joined: 17. May 2010 07:36

Re: RewriteBase in .htaccess is ignored

Postby Wiedmann » 17. May 2010 08:09

I use subdirectories of /htdocs/ for all of my websites,

In this case the usage of RewriteBase is not necessary (it's only necessary in an Alias path).

but it is being ignored.

And other (ReWrite) directives are working? (in this case RewriteBase is working and you have an other problem)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: RewriteBase in .htaccess is ignored

Postby skunkbad » 17. May 2010 08:23

Yes, the rewriting is working, but I can change the rewritebase to anything, and it does not make a difference.

For instance:

Code: Select all
RewriteEngine On
RewriteRule ^sitemap.xml /tv-sewingcenter/sitemap.php [NC]


The above works as expected, but on the production server I would have it like this:

Code: Select all
RewriteEngine On
RewriteRule ^sitemap.xml /sitemap.php [NC]


Ideally, in XAMPP I would use a rewritebase like this:

Code: Select all
RewriteEngine On
RewriteBase /tv-sewingcenter/
RewriteRule ^sitemap.xml /sitemap.php [NC]


But apache tries to find sitemap.php at /xampp/htdocs/sitemap.php, and this results in a 404 error.

I don't really understand what an Alias path is. I don't want to understand necessarily. I'd just like to be able to use a rewritebase in a subdirectory of /htdocs/ and have it work!
skunkbad
 
Posts: 13
Joined: 17. May 2010 07:36

Re: RewriteBase in .htaccess is ignored

Postby skunkbad » 17. May 2010 08:38

Wiedmann wrote:And other (ReWrite) directives are working? (in this case RewriteBase is working and you have an other problem)


I wish I knew what that problem was... because this is the case.
skunkbad
 
Posts: 13
Joined: 17. May 2010 07:36

Re: RewriteBase in .htaccess is ignored

Postby Nobbie » 17. May 2010 08:43

skunkbad wrote:I don't really understand what an Alias path is. I don't want to understand necessarily. I'd just like to be able to use a rewritebase in a subdirectory of /htdocs/ and have it work!


You should learn to understand what an ALIAS Path is, as it is the solution to your problem AND obviously you have the wrong idea about the rewritebase-Directive. It does not work like you believe, as you can see on your webserver (where it does not behave like you think). The rewritebase-Directiive is ment to be used in an ALIAS environment, not in standard DocumentRoot environment.
Nobbie
 
Posts: 8761
Joined: 09. March 2008 13:04

Re: RewriteBase in .htaccess is ignored

Postby skunkbad » 17. May 2010 18:55

Nobbie wrote:You should learn to understand what an ALIAS Path is, as it is the solution to your problem AND obviously you have the wrong idea about the rewritebase-Directive. It does not work like you believe, as you can see on your webserver (where it does not behave like you think). The rewritebase-Directiive is ment to be used in an ALIAS environment, not in standard DocumentRoot environment.


Nobbie, you are absolutely correct. I do not understand Alias or the rewritebase directive. I have one question based on your post. Is it easy to change xampp/htdocs to be an alias and get my desired functionality using rewritebase in subdirectories? I'm willing to learn more about Apache if I must, but I would rather concentrate on my work (which usually does not require this level of configuration), and I fear that I will lose a lot of time trying to make XAMPP work the way I need, or that I may never get XAMPP to work that way.
skunkbad
 
Posts: 13
Joined: 17. May 2010 07:36

Re: RewriteBase in .htaccess is ignored

Postby Nobbie » 17. May 2010 19:36

skunkbad wrote:Is it easy to change xampp/htdocs to be an alias and get my desired functionality using rewritebase in subdirectories?


I would say "yes" - but I have no idea about your skill and finally it depends on your skill.

skunkbad wrote:I'm willing to learn more about Apache if I must, but I would rather concentrate on my work (which usually does not require this level of configuration), and I fear that I will lose a lot of time trying to make XAMPP work the way I need, or that I may never get XAMPP to work that way.


It is not a question of loosing time or not - if you need it, you need it.
Nobbie
 
Posts: 8761
Joined: 09. March 2008 13:04

Re: RewriteBase in .htaccess is ignored

Postby skunkbad » 17. May 2010 20:19

My level of skill with Apache is beginner or intermediate at best. If you or anyone else can offer suggestions to accomplish what I am after, I would appreciate it. As a long time wampserver user, this is the standard functionality that I am used to. This doesn't mean I can't change the way I work, but less is more when it comes to what I have to do to make my development environment function.
skunkbad
 
Posts: 13
Joined: 17. May 2010 07:36

Re: RewriteBase in .htaccess is ignored

Postby Wiedmann » 18. May 2010 07:06

Code: Select all
RewriteRule ^sitemap.xml /sitemap.php [NC]

But apache tries to find sitemap.php at /xampp/htdocs/sitemap.php, and this results in a 404 error.

Correct, because you have defined to load the file "sitemap.php" from the DocumentRoot directory (the first slash).
If Apache should load the file "sitemap.php" from the same directory as the file "sitemap.xml", you must omit the first slash:
Code: Select all
RewriteEngine On
RewriteRule ^sitemap\.xml$ sitemap.php
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: RewriteBase in .htaccess is ignored

Postby skunkbad » 19. May 2010 06:44

I understand what you are saying now. I actually solved my problem by learning to configure vhosts, which seems to be working well so far. I do have a question related to that, but I will ask in another post since it is not directly related to this. Thank you.
skunkbad
 
Posts: 13
Joined: 17. May 2010 07:36


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 45 guests