Welcome to WebmasterWorld Guest from 54.166.48.3

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Htaccess nice url not work

     
9:16 am on Mar 11, 2014 (gmt 0)

New User

joined:Mar 5, 2014
posts:6
votes: 0


Hi,
Next problem from me....
I have web with url:
http://www.example.com/index.php?option=site&i=2&sid=23


I want to make url like:
http://www.example.com/site-2-23


Here's my code:

RewriteRule ^index.(php|html|htm)$ / [R=301,L]
RewriteRule ^([a-z0-9-_]+)/index.(php|html|htm)$ /$1/ [R=301,L]
# here all work i remove index.php and afterr add next web crash :/
RewriteRule ^([^-]*)-([^-]*)-([^-]*)$ /?option=$1&i=$2&sid=$3 [L, R=301]


I know it can be easy for some one, but I try to learn it... ...
12:40 pm on Mar 11, 2014 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10587
votes: 21


afterr add next web crash

status code?
message(s) in the web server error log file?
12:43 pm on Mar 11, 2014 (gmt 0)

New User

joined:Mar 5, 2014
posts:6
votes: 0


Error 500 - Internal Server Error

:(
12:58 pm on Mar 11, 2014 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10587
votes: 21


the translation of "Internal Server Error" is usually "go look for a message in the web server error log file".
1:09 pm on Mar 11, 2014 (gmt 0)

New User

joined:Mar 5, 2014
posts:6
votes: 0


I have only access to ftp :/
9:07 pm on Mar 11, 2014 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13248
votes: 358


RewriteRule ^index.(php|html|htm)$ / [R=301,L]

RewriteRule ^([a-z0-9-_]+)/index.(php|html|htm)$ /$1/ [R=301,L]

These are just one rule. With a minimum of changes:

RewriteRule ^([a-z0-9-_]+/)?index\.(php|html?)$ http://www.example.com/$1 [R=301,L,NS]


The target of a redirect always includes the full protocol-plus-host, on the off chance that the user also gave the wrong form of your domain name. (Search engines do this all the time on purpose.) You will also need a preceding RewriteCond looking at {THE_REQUEST}, since some "index.php" requests are the result of internal rewriting (next rule). Here the [NS] flag alone won't be enough, though it's still a good idea.

([^-]*)-

Surely you don't have URLs that begin with a hyphen? Or that have two consecutive hyphens? Here you want + rather than - each time.

Far more important:
/?option=$1&i=$2&sid=$3 [L, R=301]

That can't possibly be what you want. As written, that's an external redirect from a pretty URL to an ugly one. I have to guess you really want only an internal rewrite: [L] flag alone. Make sure this rule comes after all external redirects: not just the "index.html" redirect that you've shown, but also the domain-name-canonicalization redirect that you haven't shown.

So what I'd expect here is:
RewriteRule ^([^-]+)-([^-]+)-([^-]+)$ /index.php?option=$1&i=$2&sid=$3 [L]

You can rewrite to a raw directory name (no explicit "index.php") but why made mod_dir do the work?

I don't, however, see anything that would create a 500-class error. At most an infinite redirect-- error message from the browser-- if you've got a corresponding redirect from ugly to pretty elsewhere in the code.

I have only access to ftp

Do you mean you don't have access to your raw logs at all? Or only that the logs require sftp: (mine do) and you don't have the right software? Look around; there are plenty of free options.