.htaccess file links still show .php

Hi,

I have the following .htaccess file:


RewriteEngine on
RewriteBase /

RewriteRule ^homelogin$ http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/index.php [L]
RewriteRule ^homepage$ http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/view/index.php [L]

Now if i try visiting this link:

http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/homelogin

The URL should stay the same, yet instead it changes back to index.php…?

Why is this?

How can i fix this?

Thanks

Billy,

Please READ post #2.

Regards,

DK

Ok thanks,

On the server, i have the following folders:

bin
dev
etc
lib
lib64
public_html
usr

Then inside of the public_html folder i have:

admin
library
model
view
.htaccess
index.php

Is this the correct location for the .htaccess file?

I have also tried using the following 2 techniques:


RewriteRule ^/?homelogin$ http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/index.php [L]
RewriteRule ^/?homelogin$ index.php [L]

But neither work for me. When i type in the link homelogin it directs perfectly. The only problem is that the link name should say homelogin but instead says index.php

What am i doing wrong? How could i find out exactly where the problem is?

Billy,

The only possible problem with

RewriteEngine on

RewriteRule ^/?homelogin$ index.php [L]
RewriteRule ^/?homepage$ view/index.php [L]

… is where DocumentRoot is located (above your personal directory) and where the .htaccess file is located (in your personal directory).

DocumentRoot is important as it means that your RewriteBase / made all your redirections relative to the server’s DocumentRoot - UNDESIRABLE! It also impacts the leading / for subdirectories so you could use ^/? at the start of any regex which addresses the URI starting with your directory.

The .htaccess file’s location is important as all the regex and redirections are relative to that.

Regards,

DK

Could it be a server issue?

I need to work out why this is happening, i had to change the .htaccess file back to this:


RewriteEngine on

RewriteRule ^homelogin$ http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/index.php [L]
RewriteRule ^homepage$ http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/view/index.php [L]

As it was redirecting to an unknown page if i kept it as this:


RewriteRule ^homelogin$ index.php [L]

Can anyone kindly help me out please?

Thanks

Hey,

Thanks, i have looked at phpinfo() and have looked the the Apache2Handler, the loaded modules consist of:

core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dav mod_dav_fs mod_dav_svn mod_authz_svn mod_dir mod_env mod_mime mod_python mod_negotiation mod_php5 mod_rewrite mod_setenvif mod_status mod_userdir

mod_rewrite is listed so this should work:


RewriteEngine on

RewriteRule ^homelogin$ index.php [L]

But again if i visit this page, the url remains the same:

http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/homelogin

What could the problem possibly be?

Thanks again,

b111,

The reason is very clear to me: You are using an external absolute redirect which, by definition, will be displayed in the browser’s location box. That’s the why answer. The “how to” answer is to make the links internal and relative, i.e., (eliminate the red code - assuming that your .htaccess is in the ~ibrarhussain directory):

RewriteEngine on
[COLOR="Red"]RewriteBase /[/COLOR]

RewriteRule ^homelogin$ [COLOR="Red"]http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/[/COLOR]index.php [L]
RewriteRule ^homepage$ [COLOR="Red"]http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/[/COLOR]view/index.php [L]

If you need more information about mod_rewrite, try starting at the tutorial article linked in my signature.

Regards,

DK