Forum Moderators: phranque

Message Too Old, No Replies

Simple Permalink

Need help on a simple permalink

         

m4tt

12:11 pm on Apr 12, 2006 (gmt 0)

10+ Year Member



I am trying to work out permalinks but I have no idea!

How would I rewrite this?

www.yoursite.com/?p=home

www.yoursite.com/home/

Thanks for your help

jdMorgan

1:46 pm on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Short answer: You don't.

Long version: Change the links on your pages so that static URLs are "published" to visitors and search engines. Then use mod_rewrite to convert those static URLs, when requested from your server, back to the form needed to invoke your script(s).

For more information, see the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com] and the documents cited in our forum charter [webmasterworld.com].

Jim

m4tt

10:26 pm on Apr 12, 2006 (gmt 0)

10+ Year Member



Thanks I worked it out with this:

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME}!-d
RewriteCond %{SCRIPT_FILENAME}!-f
RewriteRule ^([^/]+)/?$ /?p=$1 [L]
RewriteRule ^news/([^/]+)/?$ /?v=news&id=$1 [L]

However I still can't work a redirect from

yoursite.com to yoursite.com/home/..

Any ideas?

m4tt

4:46 am on Apr 13, 2006 (gmt 0)

10+ Year Member



Sorry, jd I hadn't read the the forum charter. I have read the library information and have got to this point:

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME}!-d
RewriteCond %{SCRIPT_FILENAME}!-f
RewriteRule ^([^/]+)/?$ /?p=$1 [L]
RewriteRule ^news/([^/]+)/?$ /?v=news&id=$1 [L]

RewriteRule ^index\.php$ \home [R=301,L]

This re#*$!s in:

[mysite.net.au...]

I was hoping on:

[mysite.net.au...]

Can anyone advise?

m4tt

4:59 am on Apr 13, 2006 (gmt 0)

10+ Year Member



OK, now it goes to home and gives me this:

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

* This problem can sometimes be caused by disabling or refusing to accept
cookies.

Code:

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME}!-d
RewriteCond %{SCRIPT_FILENAME}!-f
RewriteRule ^([^/]+)/?$ /?p=$1 [L]
RewriteRule ^news/([^/]+)/?$ /?v=news&id=$1 [L]
RewriteRule ^index\.php$ /home/? [R=301,L]

jdMorgan

2:59 am on Apr 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As a test, disable the lines one-by-one, instead of trying to test them all at once.

I'd suspect this one of causing a loop if the DirectoryIndex of /home/ is defined as index.php.


# RewriteRule ^index\.php$ /home/? [R=301,L]

Jim