Jump to content

Links as /help/ instead of /help.php etc


Nexus10

Recommended Posts

I'm not sure what this is called (hence I couldn't google it) although I think it is doen with PHP.

 

Instead of redirecting people to mysite.com/help.php I want to redirect them to mysite.com/help/ where help.com (or another specified 'index' for that folder loads), how do I do this?

Link to comment
https://forums.phpfreaks.com/topic/206505-links-as-help-instead-of-helpphp-etc/
Share on other sites

Okay, I'm confused.

 

So far I've only added

 

Options +FollowSymLinks

 

RewriteEngine On

RewriteBase /

 

to my .htaccess file and have become lost now.

 

I want to redirect http://www.mysite.com/food/account/  (and http://www.mysite.com/food/account)

to http://www.mysite/food/account.php

 

Can someone help me with this?

 

This is what I have so far:

 

Options +FollowSymLinks

RewriteEngine On
RewriteBase /

#RewriteRule ^register(/)?$  apple/register.php [R=301]  
RewriteRule ^register\.php$ http://www.mysite.com/Food/Register/ [R=301,L]

 

which does redirect http://www.mysite.com/Food/register.php to http://www.mysite.com/Food/Register/ although that gives a 404 error then. I want http://www.mysite.com/Food/Register/ to display in the address bar but to actually use register.php to do so. Any help please?

Options +FollowSymLinks

RewriteEngine On
RewriteBase  /

RewriteRule http://www.mysite.com/food/register/$ register.php [R=301,L]

 

I go to http://www.mysite.com/food/register/ and it gives a 404 error saying /food/register/ could not be found on the server (it is uploaded in the directory).

You were trying to redirect requests from register.php to food/register, which doesn't exist. You need to rewrite requests from food/register to register.php ..

 

Try this:

 

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Sorry, /food/register/ could not be found on the website. Perhaps you wish to return where you came from: http://www.mysite.com/food/index.php www.mysite.com Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4 143.238.117.44 404 www.mysite.com

 

when I enter http://www.mysite.com/food/register/ in the address bar.

Ahh.. because you are allowing a forward slash in the pattern it's matching the one at the end so it's attempting to load food/register/.php.

 

I'm going to have to make assumptions that your .htaccess file is in your root file and that the register.php file is within the food folder

 

Options +FollowSymLinks

RewriteEngine On
RewriteBase  /

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^food/register/?$ food/register.php [NC,L]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.