Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I would like some help in formatting a url so that it is more SEO friendly. So the url is formatted below

www.portfolio.com/workDetails?url=work-title-here

but I would like the format to be

www.portfolio.com/work/work-title-here

I've tried the following

RewriteEngine on
RewriteRule ^/work/([0-9]+).html /workDetail.php?url=$1

But I got a 500x error

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
150 views
Welcome To Ask or Share your Answers For Others

1 Answer

This page appears to have a solution to what you are trying to do:

<?
    $Params = explode( '/', $PATH_INFO );

    while( list( $Index, $Value ) = each( $Params )) {
        echo "Params[ $Index ] = $Value<BR>
" );
    }
?>

Hit this URL:

http://whatever.site.com/ThisIsAProgram/these/directories/are/not/real

You should get:

Params[ 0 ] =

Params[ 1 ] = these

Params[ 2 ] = directories

Params[ 3 ] = are

Params[ 4 ] = not

Params[ 5 ] = real

And to display the PHP file as just the file name, try this:

Options +MultiViews
RewriteEngine On

RewriteCond %{THE_REQUEST} /([^.]+).php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]

EDIT: If you are wanting a more complete example, this answer covers it a lot more in depth than I could. This will definitely help you cover all your bases and understand the issue if my other linked article doesn't make it clear enough.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...