I've got an url /nl/sunglasses which is a translated page by qtranslate. I want to change this to /zonnebrillen . I prefer not to change this in wordpress since the 'sunglasses' is generated by a plugin wp-ecommerce and hardcoded.
Can I use a mod_rewrite so that /nl/sunglasses will be /zonnebrillen. And how can I let wordpress 'know' to show the according page?
Cheers!
Here's some code I modified after getting WP to take query vars in the URL including "name" as a query var. I am including the "original" .htaccess file posted by regular WP install to show the context. I have separated the rewrites to avoid problems when WP updates, or when "certain admin functions" cause it to change. P.S. I didn't test this, but similar code works for a much more complex page redirect... so try it. Let me know if it doesn't work for you, I'll test it.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^nl/sunglasses/ /zonnebrillen [NC,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Should work with WP 3.4+
Related
I am new to WordPress, creating the custom taxonomy for location in the my current URL
http://localhost/myproject/locations/us
i am need to change the URL like in that location place rename to my-project
i am trying to change the URL using Rewrite rule in ht-access file
RewriteRule ^my-project/us?$ http://localhost/myproject/locations/us [R=301,NC,L]
but its not working any one help me?
Custom .htaccess in WordPress site can bring unexpected results.
You may instead use WordPress' specific Rewrite API
Edit: if you need to use .htaccess insert your rules before the WordPress' ones.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^my-project/us?$ http://localhost/myproject/locations/us [R=301,NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This is the final .htaccess code, i tested this solution here and it works correctly.
If this solution didn't solve your case maybe there is a problem elsewhere.
Unfortunately I deleted .htaccess page from my wordpress. Now if I click on any post or category it show page could not found. What should I do now? How can I solve it?
Any body have any idea?
I would start by creating a temporary .htaccess following the default WordPress model available at their website which looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Then you will need to check the pages and everything to see what is still not working and fix it.
If your blog is on a different folder or configured differently the above may need to be changed depending on that.
For example folder structure, etc.
I am working on a wordpress blog, with the default .htaccess settings:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
In my wordpress blog, I have created a page called "mypage". Using my rewrite settings, it is shown in the address bar as http://www.mysite.com/mypage.
I am using a custom page template and am processing some things, which include the use of GET variables. For instance:
if (isset($_GET='word')) { echo $_GET['word]; }
So, http://www.mysite.com/mypage?word=dog will display "dog".
The problem I am having is rewriting the URL so that it can look like: http://www.mysite.com/mypage/dog, still being able to access "dog" as the GET variable.
I am not too good with mod_rewrite rules to begin with, but working from within a wordpress installation is throwing me an extra curveball.
Does anyone know what I need to add to my .htaccess to achieve this?
Thank you!
Try the following:
RewriteRule ^mypage/([^/])/?$ mypage?word=$1 [L,QSA]
The L flag instructs .htaccess to stop processing rules, and QSA appends the query string since you might have other GET parameters on the end of the URL.
Mod_Rewrite Documentation
I'm trying to redirect a few pages to different pages. This should be simple, but I'm missing something simple, apparently.
I have a wordpress install on a subdomain. Wordpress's generic htaccess is this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I want to redirect /farm-partners/ to /farm-partners/emilys-produce/. I'm trying to do so using the following code:
RewriteRule ^farm-partners/?$ /farm-partners/emilys-produce/ [L]
However, opening /farm-partners/ doesn't redirect, it just loads that page. What am I missing?
Use the WordPress Redirect plugin and don't mess with the htaccess.
What you are missing in your RewriteRule though, it telling it that you want an external redirect
RewriteRule ^farm-partners/?$ /farm-partners/emilys-produce/ [L,R=301]
If you use a RewriteRule, make sure it is outside the comments that indicate which parts of the file may be edited without any notice (i.e. outside the #comments marking WordPress's section of the file. Similarly if you are using W3 Total Cache or a similar plugin.)
Try this:
RewriteRule farm-partners/$ /farm-partners/emilys-produce/
I'm using Wordpress with a plugin and it's currently making urls like this: http://www.example.com/?name=the-office
I would like to redirect all similar urls to http://www.example.com/name/the-office
Current htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I tried a few things and nothing seemed to work, maybe I'm need to place the RewriteCond in the IfModule? Not sure, htaccess is foreign to me. Thanks in advance.
If you'd like a workaround that is much easier to accomplish - simply login to your wordpress admin panel, go to settings, then permalinks and there you can select how your links will look like. Select the last option (Post name) to get only post names in the urls.