Welcome to WebmasterWorld Guest from 54.158.228.55

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Rewriting domain.com/page to domain.com/page/

     
12:59 am on Sep 29, 2006 (gmt 0)

5+ Year Member



Hi Apache gurus,
I need help from you. I own a wordpress blog and have basic mod_rewrite in place (for permalinks and 301 non www to www). My 301 code for rewriting non www to www looks like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
</IfModule>

Now I want to rewrite all pages generated by wordpress (ex. www.domain.com/page1; www.domain.com/category/page1) to pages with / at the end of them, because of dup. content issues. However, I do not want to rewrite real files, like wp-admin.php or wp-login.php, and basically all phisical files on server. Just those already rewritten. Actually just 301 redired from page to page/ will be great, again w/o having any affection to phisical files.

I hope I was clear.

Thank you in advance,
Manca

2:50 pm on Sep 29, 2006 (gmt 0)

5+ Year Member



Please, anyone?
7:21 pm on Sep 29, 2006 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Writing the code is easy, but defining which URLs should be rewritten and which should not be rewritten is the hard part. The decision must be based on the contents of the requested URL, and whether that URL exists as a file or directory.

You can use RewriteCond %{REQUEST_FILENAME} -f

to check for file exists. Or you can use

You can use RewriteCond %{REQUEST_FILENAME} !-f

to verify that the file does not exist.

You can use the pattern of the RewriteRule to test the requested local URL_path.

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

Jim

10:24 pm on Sep 29, 2006 (gmt 0)

5+ Year Member



jdMorgan, thanks for help.
I've sorted it anyways....Yes it had to do with condition whether is file or directory, but i made it work ;)

If anyone needs a code, feel free to let me know and I'll be more than happy to share it with u ;)

9:38 pm on Oct 4, 2006 (gmt 0)

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



Please post the code here....
 

Featured Threads

Hot Threads This Week

Hot Threads This Month