Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-28-2008, 08:22 PM mod_rewrite for php
Skilled Talker

Posts: 94
Trades: 0
I know this has been discussed many times but I need to ask...

I have
RewriteRule ^(.*)\/$ $1.php [nc]

Which works if you type in www.sitename.com/page/

However you can still type in www.sitename.com/page.php

What is the string so that even if a .php is typed in it redirects you to without an ext or just gives you an error page?
IG88 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-29-2008, 07:01 AM Re: mod_rewrite for php
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
RewriteRule /page.php /page/ [R=301,L] and add L to nc in your square brackets
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 07-29-2008, 11:24 AM Re: mod_rewrite for php
Skilled Talker

Posts: 94
Trades: 0
Will I have to write that for ever single page?
IG88 is offline
Reply With Quote
View Public Profile
 
Old 07-29-2008, 07:26 PM Re: mod_rewrite for php
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
You can use wildcards like you did in your original rewrite rule. Just follow mtishetsky's structure.

RewriteRule /(.*).php /$1/ [R=301, L]

The all encompassing (.*) may not be the one you ideally want, depending on your URLs.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 07-29-2008, 08:05 PM Re: mod_rewrite for php
Skilled Talker

Posts: 94
Trades: 0
By using either of those configurations, and also adding L to the NC, I get a 500 internal server error.

Here is what I have...

RewriteRule ^(.*)\$ $1.php [nc,L]
RewriteRule /(.*).php /$1/ [R=301,L]

Any ideas?

Last edited by IG88; 07-29-2008 at 08:08 PM..
IG88 is offline
Reply With Quote
View Public Profile
 
Old 07-30-2008, 05:15 PM Re: mod_rewrite for php
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Try this. You should only need the one line.

RedirectMatch 301 /(.*).php http://www.yourdomain.com/$1/
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 07-30-2008, 06:40 PM Re: mod_rewrite for php
Skilled Talker

Posts: 94
Trades: 0
That just gives me a 404 error. Forbidden. And changes all the URL's to http://www.site .com/profile/?user=profile
IG88 is offline
Reply With Quote
View Public Profile
 
Old 07-30-2008, 06:47 PM Re: mod_rewrite for php
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Could you provide two exact URLs and old one and where you want it to point to?

Also what else do you have in your .htaccess file. It's possible you have other rules that are causing conflicts.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 07-30-2008, 08:00 PM Re: mod_rewrite for php
Skilled Talker

Posts: 94
Trades: 0
I think you are correct. I am going to send it to you.
IG88 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to mod_rewrite for php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.88697 seconds with 12 queries