I want to put a static permalink in the .htaccess file. For example when I go to the http://www.example-page.com/testsite the server redirect to this http://www.example-page.com/wp-admin/example.php?test=data
My problem is that I didn't want to destroy the permalink structure of the WordPress blog.
My .htaccess file code looks like as follows:
# 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
Thanks for your help.
Add this rule after RewriteBase /
RewriteRule ^testsite$ /wp-admin/example.php?test=data [R=301,L]
It will intercept only the specified URI and redirect it.
Other WP's permalinks should work as usual.
Related
I have a Wordpress site that has a rewrite rule. I also have a non-wordpress folder, but I can't access it because of this rule. So I read that i should enter RewriteEngine Off in the htaccess of the non-wordpress folder, unfortunately I still get an Error 404 on that page (it works fine if I remove the Wordpress rewrite).
Here is the htaccess in the root:
# 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
What am I doing wrong?
Many thanks!
Matt
Add this right under RewriteBase /:
RewriteRule ^folder/ - [L]
where folder is the folder you want to exclude.
We had several domains parked on top of our main website. This was a normal HTML website and we used the following redirect so that the domain would 301 redirect to the proper url to avoid getting dinged by Google.
rewriteCond %{HTTP_HOST} ^ourmainsiteurl\.com$
rewriteRule ^.*$ http://www.ourmainsiteurl.com%{REQUEST_URI} [R=permanent,L]
So the above htaccess code just rewrites the url to www.ourmainsiteurl.com, which is what we want.
Now here's the problem... we installed Wordpress and it has the following default htaccess code:
# 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 to add my redirect code in but that broke Wordpress. Can anyone tell me what I need to use to make this work?
Simply put I want all the parked domains (ie: parkedurl1.com, parkedurl2.com, etc) to be redirected to www.ourmainsiteurl.com with the htaccess file.
Make sure the redirect is before any wordpress rules:
rewriteCond %{HTTP_HOST} ^ourmainsiteurl\.com$ [NC]
rewriteRule ^.*$ http://www.ourmainsiteurl.com%{REQUEST_URI} [R=permanent,L]
# 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
If it's still not working, check to see if wordpress has something turned on that is redirecting, or adding/removing the "www" from the hostname.
I've been trying to redirect a url in my wordpress wp-admin dashboard from /wp-admin/admin.php?page=for_buyers to wp-admin/for-buyers/.
Is there any way to correctly do this? I've tried modifiying my .htaccess file as can be seen below, but it's not working.
# 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]
RewriteRule ^wp-admin/for-buyers/$ /wp-admin/admin.php?page=for_buyers
</IfModule>
# END WordPress
UPDATE: I have been able to do it, but it now causes a redirect loop.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/wp-admin/admin.php?page=for_buyers wp-admin/for-buyers/$
</IfModule>
You do not need to redirect your url but just rewrite it.
Take a look here
Hope this helps you!
I have a postNuke site that I'm currently transferring to Wordpress and I would like the format of the old site not to be lost in the conversion. I've tried to play with it but I'm going nowhere fast!
The current site currently rewrites the URL to :
domain.com/Article1234.html
where 1234 is the internal id number of the article.
The ID in the old site is the same in the new site. The URL in the new wordpress site currently rewrites to a custom structure :
/%category%/%postname%
Here is what is in the .htaccess file:
# 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
What is needed to be done to redirect the old format to the new one? Change rewrite rule in htaccess? 301 redirect? wordpress plugin for rewriting?
If you don't have a lot of articles, you can use RedirectPermanent, but you have to write yourself the directives in your .htaccess file.
Or you can use .htaccess like this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^Article([0-9]+)\.html$ /index.php?p=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This will rewrite Article1234.html to index.php?p=1234, then wordpress will make a 301 redirection.
Be careful when modifying permalinks since .htaccess could be override, to avoid this you can place custom rewrite rules before # BEGIN WordPress.
I am trying to rewrite http://www.domain to http://domain in a wordpress installation, but it looks like it's making the url loop from http://www to http:// and back to http://www, etc.
This is my htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
What's wrong with this code?
WordPress can do this for you. Remove the .htaccess stuff you've added, and go to Options -> General and change your site's URL.
It looks like you made changes to your .htaccess file that aren't necessary. To fix this problem change your .htaccess file back to default wordpress value which is:
# 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
Now that your .htaccess file is back to normal, login to your wordpress dashboard and click on Setting -> General. You'll see two text boxes labeled "WordPress address (URL)" and "Site address (URL)". Change the URL in both of these fields and you can remove the www part if you don't want that in your site URL. Save the changes and you're good to go! Here's a screenshot of the settings page so you can see the exact fields:
Hope this answers your question!