GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   htaccess question (https://gfy.com/showthread.php?t=517384)

X37375787 09-16-2005 01:43 PM

htaccess question
 
On one of my sites I run WordPress and have permalinks setup via mod_rewrite. Currently, the posts appear as directories like

http://www.domain.com/category/postname/

I know I could change the permalink structure in the script itself to postname.html - but then the pages indexed by SEs would return 404s all across the site.

Is there a way to divert requests for directories to the virtual .html files as specified by the new rewrite rules? :helpme

X37375787 09-16-2005 01:44 PM

So

http://www.domain.com/category/postname/

would automatically 301 to

http://www.domain.com/category/postname.html

pornpf69 09-16-2005 01:46 PM

I am sorry but I can help on this matter...good luck with it!

X37375787 09-16-2005 01:57 PM

Quote:

Originally Posted by pornpf69
I am sorry but I can help on this matter...good luck with it!

I guess you mean to say you can't help with this matter :thumbsup

Realpascal 09-16-2005 02:11 PM

Bump for you.

kektex 09-16-2005 02:20 PM

try webmasterworld.com
They have a bunch of very knowledgeable people on the apache forum

The Sultan Of Smut 09-16-2005 02:26 PM

I searched for this:

http://www.google.com/search?sourcei...q=htaccess+301

and found this:

http://www.tamingthebeast.net/articl...1-redirect.htm

psili 09-16-2005 02:31 PM

Haven't tested it, but something like:

Code:

RewriteEngine on
RewriteRule categories/(.*)/? categories/$1.html [R=301]


psili 09-16-2005 02:36 PM

Here's a handly little rewrite cheat sheet for you mod rewrite fans from some dude who apparently digs on jack daniels:

http://www.ilovejackdaniels.com/mod_...heat_sheet.png

pornpf69 09-16-2005 02:51 PM

Quote:

Originally Posted by Equinox
I guess you mean to say you can't help with this matter :thumbsup

that is what I meant...

J.P. 09-16-2005 03:03 PM

psili, that code won't work, because .* matches everything 0 or more times and /? matches a character 0 times or once... so this code of yours would match
http://www.domain.com/category/postname.html also

Code:

RewriteEngine on
RewriteRule $categories/([^/\.]+)/?^ categories/$1.html [R=301]

this would match everything except for / and . 1 or more times, so http://www.domain.com/category/postname.html would not match...

This is not tested also, so maybe there are errors in this too :)

Note that the above code will work in .htacces only, to use it in httpd.conf you should add / right before the categories, like this:

Code:

RewriteEngine on
RewriteRule $/categories/([^/\.]+)/?^ /categories/$1.html [R=301]

Julio

jimmyf 09-16-2005 03:24 PM

Quote:

Originally Posted by The Sultan Of Smut


tamingthebeast.net

dam good one, explanes it the best I've ever seen. :thumbsup

X37375787 09-16-2005 07:25 PM

thanks for the info guys. The example I posted was rather specific, the solution I need will be a little more complex since I am looking into redirecting URLs in different subfolders, not just /categories/. But nonetheless, I can start with the info that was posted here.

J.P. 09-17-2005 03:47 AM

Not a problem:

Code:

RewriteEngine on
RewriteRule $(dir1|dir2|dir3|dir4)/([^/\.]+)/?^ $1/$2.html [R=301]

Julio


All times are GMT -7. The time now is 03:08 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123