Forum Moderators: phranque

Message Too Old, No Replies

Help me Jim

Rewerite Rule

         

Trust

10:27 pm on Aug 20, 2011 (gmt 0)

10+ Year Member



Hi i have one problem with my rewrite rule!
I have this code.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
rewriterule ^([a-zA-Z0-9-a-z_]+)$ /ladydetails.php?user=$1 [L]
rewriterule ^([a-zA-Z0-9-a-z_]+)$ /user.php?cid=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(([^/]+/)*[^./]+)$ $1.php
</IfModule>

Ok what is the problem?
Frist rule as you can see that with /ladydetails.php?user=$1 [l] will transform my website like this: example.com/someuser ok all is good work frin and also work fine too thant two rule with /user.php?.....
Ok but as you can see i want transform all pages from my website without extension .php and my fris page on website is this:
example.com/featured.php ok work fine that rule if i write example.com/featured will work but BAD will redirect me on frist rule that with ladydetails.
I was tryed to add on slash / before $ yes work fine then url will be:example.com/featured/ ok right but then i need to change all code in my files .php i need to put also in all php files this slash / before src="/........" and i don`t like now to change all my files for this rule.
So what i want is to work fine rule with remove extension .php if i type example.com/featured to display me correctly page with name feature.php can you help me Jim?
Thank you,
Jason.

[edited by: Trust at 11:00 pm (utc) on Aug 20, 2011]

g1smd

10:32 pm on Aug 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I can see at least four different problems with the code, problems that Jim has mentioned hundreds of times over and over in many previous threads.

Please edit your post to remove "smilestopper" and instead tick the "Disable graphic smile faces for this post?" box on the web form.

Use only example.com in the forum. This reserved domain name suppresses forum auto-linking.

To remove .php from your URLs, remove it from the links on the pages of your site. A URL "exists" as soon as you create a link that can be clicked on.

You need a rewrite to kick in after that link is clicked, and you need a redirect to catch requests for the wrong URL (such as found in stale SERPs or old bookmarks) and redirect the user to the new URL.

There's several example threads in the forum library.

[edited by: g1smd at 10:46 pm (utc) on Aug 20, 2011]

Trust

10:37 pm on Aug 20, 2011 (gmt 0)

10+ Year Member



Please g1smd can you give me the link from the threads, or can you help me my head still goind to explose.
Thank you g1smd.

Hmm you i think you not understand me, my problem is this! featured.php i want transform it in featured without .php ok is work the last rule is for this but not work good if i type mywebsite.com/featured will be show me the page with username that with ladydetails and i notunderstand why and how i can do it to work it.
And one more think problem is with all website all pages if i type without .php will show me the page with ladydetails that rule frist.

Trust

11:03 pm on Aug 20, 2011 (gmt 0)

10+ Year Member



So someone can help me? thats not work what you say g1smd.

How i can do it this what you say me:
You need a rewrite to kick in after that link is clicked, and you need a redirect to catch requests for the wrong URL (such as found in stale SERPs or old bookmarks) and redirect the user to the new URL.
?