Need Help: Rewriting Wordpress Permalinking with Plugin

Discuss practical ways rearrange URLs using mod_rewrite.

Need Help: Rewriting Wordpress Permalinking with Plugin

Postby jingo455 » Wed Oct 22, 2008 9:45 am

I am currently trying desperately to rewrite in .htaccess for a wordpress plugin I'm using and can't get any further support for (despite paying $400 for it!).

Currently my links look like WITH permalinks on:
mysite.com/blog/post.html/variable/

What I WANT it to look like is
mysite.com/blog/variable/post.html

or the best might just be detecting the .html ending and turning it into
mysite.com/blog/post/variable.html

(though I'll settle for the variable folder to be anywhere BEHIND the .html at this point, the variable would also apply to the main page as well)

What is looks like with permalinks off is:
mysite.com/blog/wp-content/plugins/cool/plugin.php?l=VARIABLE&u=http://www.mysite.com/blog/post.html

I need the variable in the folder structure to move from the end to the beginning basically and my apache knowledge is very limited (to basic tutorials that only further confuse me).

Code: Select all
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/

RewriteRule ^([-a-z0-9\.]+)/([-a-z0-9\.]+)/?$ /plugin.php?l=$1&u=http://www.mysite.com/blog/$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

# END WordPress


As you can see that clearly doesn't work, and it in fact causes a 404 error in my dashboard (but the site seems unaffected). Can anyone please help me?

Thank you in advance.
jingo455
 
Posts: 2
Joined: Wed Oct 22, 2008 9:36 am

Postby richardk » Wed Oct 22, 2008 1:26 pm

The .htaccess file is in /blog, right?

Try, for /blog/variable/post.html
Code: Select all
Options +FollowSymLinks

# BEGIN WordPress
<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteRule ^([-a-z0-9\.]+)/([-a-z0-9\.]+\.html)$ /blog/wp-content/plugins/cool/plugin.php?l=$1&u=http://www.mysite.com/blog/$2 [NC,QSA,L]

  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby jingo455 » Wed Oct 22, 2008 11:35 pm

Yes, it's in /blog/, I tried the new code it doesn't work either, but probably cuz it still looks like my code (and my code is probably wrong). This is all for a translator plugin to re-write the query for it so the language doesn't appear at the end, but the front. Like the current method shows as "post.html/de/ instead should be /de/post.html, or the other method I described might work best with /post/de.html

Oh and since I know the characters for the VARIABLE each time, maybe a simpler way would be some sort of internal rewrite for each one....

Like
Code: Select all
RewriteRule ^$1.html/de/  ([a-zA-Z0-9]*)/de.html  [QSA]


But it didn't worked for me either (to change just the de, and then I could add each seperate one).

How would I rewrite the query string (the plugin.php one) to change up the URL structure and bypass the current permalinking structure?

Is it possible? All I really need is a way to get that simple code above to work even that basic one would be great. Thank you for your time.
jingo455
 
Posts: 2
Joined: Wed Oct 22, 2008 9:36 am

Postby richardk » Thu Oct 23, 2008 6:02 am

Yes, it's in /blog/, I tried the new code it doesn't work either, but probably cuz it still looks like my code (and my code is probably wrong).

There are differences, mainly the addition of "/blog/wp-content/plugins/cool".

What happened when you went to /blog/variable/post.html?
Is the path correct (/blog/wp-content/plugins/cool/plugin.php)?
What happens if you replace QSA with R?

This is all for a translator plugin to re-write the query for it so the language doesn't appear at the end, but the front. Like the current method shows as "post.html/de/ instead should be /de/post.html, or the other method I described might work best with /post/de.html

Oh and since I know the characters for the VARIABLE each time, maybe a simpler way would be some sort of internal rewrite for each one....

You have to match the URL you want, and rewrite to the working URL.

You could try
Code: Select all
^(en|de|fr|etc)/(.+\.html)$

instead of
Code: Select all
^([-a-z0-9\.]+)/([-a-z0-9\.]+\.html)$
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 1 guest

cron