Welcome to WebmasterWorld Guest from 54.226.2.31

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod rewrite & Windows

Just give up?

     

gsmith

3:14 pm on Mar 12, 2009 (gmt 0)

10+ Year Member



I'll save readers the sorry details, but I've been trying and trying to set this up on Vista and nothing seems to work. The module is running, but attempts to rewrite fail. The pages are located in the Documents folder (by means of an Alias) so that I can modify the pages without Administrator privileges.

I did a lot of searching on the Internet (including some threads on this forum), and found that others have had similar difficulties. This isn't specific to Vista; people have had the same problems on XP and 2000.

I've decided do this by placing .htaccess files on the host server, which is a Linux account, and using a test home page to debug it. I'll just use "real" URLs on my development PC.

Have others here been forced to the same conclusion?

Caterham

5:07 pm on Mar 12, 2009 (gmt 0)

10+ Year Member



but attempts to rewrite fail.

I.e. HTTP 404 for requests which should match your rule? Please make sure that

AllowOverride FileInfo
is set for that directory and post

- the physical and URL path to your .htaccess file
- the way teh request was mapped to the file system (you're talking about an Alias, so you're using

Alias / "C:/path.../"
?
- the URL-path you requested
- RewriteRules used.

gsmith

7:01 pm on Mar 12, 2009 (gmt 0)

10+ Year Member



Thanks Caterham.

Yes, I'm getting HTTP 404s, and AllowOverride is set to All for that directory. Otherwise:

- Physical path: C:\Users\MyName\Documents\MyProject\MyDomain
(no spaces anywhere).
- Corresponding URL: [localhost...]
- Alias Directive: Alias /MyDomain C:/Users/MyName/Documents/MyProject/MyDomain
- Path requested: [localhost...]
- Rewrite rules:

RewriteBase /MyDomain
RewriteRule ^/MyDomain/page1\.html$ /page2.html

plus many different permutations of this humble attempt at creating a rewrite rule. By this point I could write a book about writing rewrite rules, but I'd have to rewrite it if I ever figure out how to rewrite correctly.

vincenz66

7:35 pm on Mar 12, 2009 (gmt 0)

5+ Year Member



Hi,
I have been using Windows Server 2003 with Apache 2.054, and have been able to get mod_rewrite to work. The biggest hurdle was needing to change my custom 404 page be referenced by .htaccess instead of httpd.conf, as the 404 page was intercepting the mod_rewrite url as a bad request.

This site was the best resource for me getting started:
[yourhtmlsource.com...]

gsmith

7:45 pm on Mar 12, 2009 (gmt 0)

10+ Year Member



Thanks vincenz66, I'll look into that immediately.

edit: Wait a minute, I don't have a custom 404 page.

vincenz66

8:21 pm on Mar 12, 2009 (gmt 0)

5+ Year Member



Ok. Make sure the httpd.conf file is not directing 404 errors to a standard page. Search on 'ErrorDocument' directive. Also, make sure the 'mod_rewrite.so module' is enabled in the conf file and exists on your server usually 'C:\Program Files\Apache Group\Apache2\modules' , you probably already did this, but just in case.

Also can you please post your Rewrite commands?

Here is one of mine for reference, but there are a number of ways to doing it:
---------------------------------------

# Rewrite URL for SEO #
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

## Index Pages ##
RewriteRule ^events/index/([A-Za-z]+)$ /eventinfo/index.php?region=$1

vincenz66

8:25 pm on Mar 12, 2009 (gmt 0)

5+ Year Member



The variable captures (A-Z) capital letters, (a-z) lower case letters, and the '+' sign signifies the length of the variable may vary in length. If your capture includes numbers, you would have to add (0-9).

Hope this helps!

Caterham

8:39 pm on Mar 12, 2009 (gmt 0)

10+ Year Member



RewriteBase /MyDomain
RewriteRule ^/MyDomain/page1\.html$ /page2.html

that should read

RewriteEngine on
RewriteBase /MyDomain/
RewriteRule ^page1\.html$ page2.html [L]

g1smd

9:34 pm on Mar 12, 2009 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



For efficiency, you nearly always replace the [A-Za-z] pattern, with just [A-Z] and the [NC] flag.

gsmith

10:48 pm on Mar 12, 2009 (gmt 0)

10+ Year Member



Well, so long as people seem to find this interesting I'll continue.

I moved

RewriteEngine on

out of httpd.conf and into .htaccess. I then comment out all text except for that one line (the same result happens whether I do or don't). Once that has been done, trying to access any page, even ones that I can normally access, produces an HTTP 403 - Forbidden. In the FF window the following message appears:

"You don't have permission to access /MyDomain/whatever.html on this server."

Trying [localhost...] which normally lets me view index.html returns a 403 with

"You don't have permission to access /MyDomain/ on this server."

Does this make sense to anyone?

Caterham

8:37 am on Mar 13, 2009 (gmt 0)

10+ Year Member



produces an HTTP 403

You don't have FollowSymlinks enabled, see the Options [httpd.apache.org] directive. That should tell you your error.log as well.

gsmith

12:04 pm on Mar 13, 2009 (gmt 0)

10+ Year Member



Yes, adding FollowSymlinks did it. Without really thinking I figured that that's only for *nix, but NTFS has Reparse points which are for the same purpose.

Thank you!

 

Featured Threads

Hot Threads This Week

Hot Threads This Month