Forum Moderators: phranque

Message Too Old, No Replies

Really simple rewrite question

         

jameschambers

1:35 pm on Nov 26, 2006 (gmt 0)

10+ Year Member



Hi everyone

I am cleaning up the urls on my site using htaccess and have run into a problem.


Options +FollowSymlinks
RewriteEngine on
RewriteBase /
Rewriterule ^home/ index.php [NC]

works fine, but...


Options +FollowSymlinks
RewriteEngine on
RewriteBase /
Rewriterule ^about/ about.php [NC]
gives a 404 error.

Basically I can't rewrite with the same spelling, and am stumpted as to what to do.

Any help gratefully received.

James

jdMorgan

2:13 pm on Nov 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Basically I can't rewrite with the same spelling, and am stumped as to what to do.

The problem isn't that simple, because you're not rewriting to the same "spelling" -- "about/" is not equal to "about.php" at all. It differs in the sixth character position, and it differs in length. So that's probably not the problem.

It is more likely that the problem has to do with the *roles* these URLs play on your site, and how other directives are set up to support those roles. For example, is "about.php" the index file in the directory "about/"? If so, there may be a DirectoryIndex directive defined that is interfering with the desired operation. Alternatively, it may have to do with where "about/" and "about.php" are located; Your code assumes they are located in the same folder as your code.

Without a lot more information on what you are trying to accomplish and what problem you intend to solve, I can't offer much more.

Jim

jameschambers

2:22 pm on Nov 26, 2006 (gmt 0)

10+ Year Member



Hi Jim, thanks for replying so quickly.

It's a fairly simple site, all the .php files and the .htaccess file are located in the root folder, and the only other folder within that is called 'images/'. Having experimented a bit more I've found that I can't seem rewrite to any url that has the same name as one of my php files.

For example there is a file called iyc.php. If I try to rewrite index.php to iyc/ like this...

Rewriterule ^iyc/ index.php

I get a 404, like the about/.

Experimenting further, I found that this works...

Rewriterule ^inde/ index.php

and this gives a 404.

Rewriterule ^index/ index.php

Thanks for your help

jdMorgan

7:10 pm on Nov 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, how about a wild guess...

Does this work?


Options +FollowSymlinks [b]-MultiViews[/b]
RewriteEngine on
RewriteBase /
Rewriterule ^about/ about.php [NC]

If so, then you've got content-negotiation [httpd.apache.org] enabled, and it's interfering with your rewrite code.

Jim

jameschambers

1:24 pm on Dec 6, 2006 (gmt 0)

10+ Year Member



Sorry for the late reply, that did the trick.

Thanks a lot Jim!