Forum Moderators: coopster

Message Too Old, No Replies

htaccess help

mod rewrite

         

fernan

4:20 am on Mar 9, 2005 (gmt 0)

10+ Year Member



hi, i am new to php and htaccess mod rewrite
i just wanna know how can i change my url

from
[mysite.com...]

to
[mysite.com...]

is this possible

or like this
[mysite.com...]

and another htaccess question i want to chage
[mysite.com...]

to
[mysite.com...]

because if a visitor clicks the /directory they will see whats inside that directory so better change it to index.php

many thanks
fernan

ironik

4:52 am on Mar 9, 2005 (gmt 0)

10+ Year Member



Someone helped me out with the same sort of question last week, hopefully it'll help you too:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule .* /odp.php [L]

Basically, any non directory or non file gets diverted back to your php script (in your case odp.php). Once it's diverted use the variable $_SERVER['REQUEST_URI'] to access the URI string... then you can do pretty much anything with the navigation.

If you want to stop people from being able to view the apache directory listing, just add this to your .htaccess file:

IndexIgnore *

(You can, if you like, restrict it to certain file types.... e.g. IndexIgnore *.gif, *.jpg, *.png prevents image files from being listed).

happy htaccessing!

fernan

5:51 am on Mar 9, 2005 (gmt 0)

10+ Year Member



Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule .* /odp.php [L]

i added this to my htaccess but i got internal server error. :)

[qoute]Basically, any non directory or non file gets diverted back to your php script (in your case odp.php). Once it's diverted use the variable $_SERVER['REQUEST_URI'] to access the URI string... then you can do pretty much anything with the navigation. [/qoute]

i dont really understand your terms but is their any way i can make my urls work?

thanks

ironik

9:18 pm on Mar 9, 2005 (gmt 0)

10+ Year Member



I've tested the directives and they should work fine, perhaps your odp.php is not in the sites root. You have to include a relative path... if the odp.php file is in a folder called directory/ then you have to add that to the directive, no matter where the .htaccess file is stored.

RyanM

1:58 am on Mar 10, 2005 (gmt 0)

10+ Year Member



You should also make sure that your host allows mod rewrites, many dont as a bad rule can quite easily crash a system

Gruessle

8:13 am on Mar 10, 2005 (gmt 0)

10+ Year Member




Sample changing this:
[excample.com?category=23...]

to this:
[excample.com...]
other words:
"?category=x," variable to, "directory-x.html"

Do this:
"RewriteRule ^directory-([0-9]*).* index.php?category=$1 [L,NC],".

dosdawgs

7:06 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



i am fighting the same battle. i have tried hundreds of examples, got some nice errors and all, just cant seem to get the ext to change from .php to .html here is an example of what i have right now loaded in the directory /directory
RewriteEngine On
RewriteRule ^index.html index.php
RewriteRule ^home.htmlhome.php
RewriteRule ^recent.html recent.php
RewriteRule ^search_detail.html search_detail.php
RewriteRule ^improvemylisting.html improvemylisting.php
RewriteRule ^register.htmlregister.php
RewriteRule ^tell.htmltell.php
RewriteRule ^terms_of_use.htmlterms_of_use.php
RewriteRule ^privacy.htmlprivacy.php
RewriteRule ^contactus.htmlcontactus.php
RewriteRule ^login.htmllogin.php
RewriteRule ^password.htmlpassword.php
this does nothing........
could somebody please give me some pointers/

thank you very much
dosdawgs

soquinn

7:13 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



I've used this in htaccess:

AddType application/x-httpd-php .htm .html
Options -Indexes

to get .html to act like .php and to block access to open directories (i.e., no index file).

dosdawgs

7:27 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



thanks for the reply soquin,
however i am not following you on that one. i need to get the .php files to show as .html for spidering and thats really it.

i pasted my .htaccess which turned out a little jumbled.
this has got to be one of the most annoying things i have ever attempted.

what am i missing here.

later,
dosdawgs

[edited by: coopster at 1:59 am (utc) on Mar. 12, 2005]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]

soquinn

8:30 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



i need to get the .php files to show as .html for spidering and thats really it.

As far as I know your .php pages will spider just like any .html no need to change them.

Thought you were going the other way .html to .php in order to run code on a html page. What are you expecting to happen at that url?

dosdawgs

11:04 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



soquinn
i want the .php? to show as .html
the two examples i showed were only using .php however
i have this url as well
/classifieds/showads.php?catid=53
and then there are a few like this
/classifieds/showads.php?catid=1&sid=981429071e87992115e76c91d86e3f7b
now i dont have a clue why its doing sessions, but at any rate, those are really what i am needing to show the .html instead of the path .php?catid=1&sid=

at any rate. thanks for your replies.

later,
dosdawgs

[edited by: coopster at 2:01 am (utc) on Mar. 12, 2005]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]

soquinn

12:26 am on Mar 13, 2005 (gmt 0)

10+ Year Member



Why do you want the .php to show as .html?

Anyway I think your htaccess should look like:

Options FollowSymLinks
RewriteEngine on

RewriteRule ^index/(.*).html$ index.php [L]
RewriteRule ^home/(.*).html$ home.php [L]

maybe some else can confirm?

andyat11

12:27 am on Mar 13, 2005 (gmt 0)

10+ Year Member



I think so to