homepage Welcome to WebmasterWorld Guest from 54.224.53.192
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

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

5+ Year Member



 
Msg#: 3101269 posted 12:59 am on Sep 29, 2006 (gmt 0)

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

 

manca

5+ Year Member



 
Msg#: 3101269 posted 2:50 pm on Sep 29, 2006 (gmt 0)

Please, anyone?

jdMorgan

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



 
Msg#: 3101269 posted 7:21 pm on Sep 29, 2006 (gmt 0)

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

manca

5+ Year Member



 
Msg#: 3101269 posted 10:24 pm on Sep 29, 2006 (gmt 0)

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 ;)

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3101269 posted 9:38 pm on Oct 4, 2006 (gmt 0)

Please post the code here....

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved