mod_rewrite problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
caedo
Forum Newbie
Posts: 5
Joined: Tue Jul 22, 2008 12:48 pm

mod_rewrite problems

Post by caedo »

Good day,


Im using mod_rewrite to redirect users to existing pages from fake, user friendly pages.
The problem that Im having is that when Im redirected to the page, the url changes to the one of the existing page.

Here is my .htaccess code:

Code: Select all

 
DirectoryIndex index.php
 
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule  ^(.+)/(.+).htm$ http://mydomain.com/front-ctrl.php?url=%{http_host}&cat=$1&page=$2[L]
 
 

So, the issue is, how can I maintain the fake, user-friendly instead of being redirect to the real url?

thanks in advance.

caedo.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: mod_rewrite problems

Post by Zoxive »

caedo wrote: So, the issue is, how can I maintain the fake, user-friendly instead of being redirect to the real url?

thanks in advance.

caedo.
Most likely it is because you could be redirecting to a different domain. As long as its the same domain it should not hard redirect.
caedo
Forum Newbie
Posts: 5
Joined: Tue Jul 22, 2008 12:48 pm

Re: mod_rewrite problems

Post by caedo »

Mmmmm....that makes sense. Doing tests using the same domain, there wasnt any problem(but it didnt show me the right content), as soon as I change the domain, all went wrong. Now the problem is, how can I access that script if it isnt in the domain's directory?

The file structure goes like this:

/ <-- mydomain.com // Here is where I access the front-ctrl.php script
/dir1
/dir2
front-ctrl.php
/domain <-- this is the domain I use
.htaccess


I want to access the front-ctrl.php from the /domain. Is the a way to do it?
Post Reply