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.
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.
This is my htaccess for wordpress
# 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 create a category named "hotels"
I like to change my url via mod rewrite apache module.
My current url like this
http://www.mydomains.com/hotels?state=newyork&country=us
But I want url like below:
http://www.mydomains.com/hotels/us/newyork
How can i achieve this?
I tried to get url like this:
http://www.mydomains.com/hotels/newyork from http://www.mydomains.com/hotels?state=newyork
so i used this line after the rewrite rule but it was not worked.
RewriteRule ^hotels/([^/]*)$ /hotels/?state=$1 [L]
Can some one please help me?
Thanks in advance
Is there a particular reason you are trying to change permalinks via htaccess? This is more effeciantly done thru the wordpress dashboard under
Settings> Permalinks
You can choose a custom permalink structure or choose from the pre selected ones given thru wordpress.
Put this before the RewriteConds:
RewriteRule ^hotels/([^/]+)/?$ hotels?state=$1
You don't want the [L] flag because it prevents Wordpress from ever processing it.
I developed a simple wordpress site for a company.
Today they called me and said that some of the pages can't be visited.
So i checked it out , and seems like 3 menu options for apparent reason just stopped working. They said they haven't done any changes.
http://oi40.tinypic.com/ofqcev.jpg
Check the permalink it says says "projektledning" like it should be , and wordpress refuses to find the page.
http://oi40.tinypic.com/16h9mcg.jpg
And i tried for no reason to change the permalink and i've added "-1" to the link and bam its working...
What should i do to make the permalink work as the regular name it should be?
Try toggle permalink once under admin - settings - permalinks. Make sure you're server has write access to your .htaccess file before doing this.
.htaccess should look 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
At the last row, make sure there's a space between . and /
Also check your permalinks for any typos (spaces).
IF your url is foo.bar/something, make your .htaccess look like:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /something/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /something/index.php [L]
</IfModule>
# END WordPress
Hope this helps!
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/