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.
Related
When I try to change my WordPress Permalink settings, links to posts and pages return a 404 page. I have found the only way to get them to work is to either use Plain permalinks or to include /index.php/ in my permalink url, like domain.com/index.php/postname. How can I get them to work without index.php being part of the URL?
My .htaccess is below, and I have also used the .htaccess suggested at https://wordpress.org/support/article/using-permalinks/#creating-and-editing-htaccess, but changes to the permalinks puts the code below back into the htaccess file. Mod_rewrite is enabled on my Apache server.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
See below, the .htacess file from Wordpress. If I remove the part starting from # BEGIN WordPress, all the image file URLs will be changed to d28rt1vkpsdxas.cloudfront.net/someimage.png successfully.
However, all the internal links will be unable to access (only the home page can access). The error is
Not Found The requested URL /shop/ was not found on this server.
But if I keep the part start from # BEGIN WordPress, the CDN redirect will not work anymore. All photos are missing.
Options +FollowSymlinks
RewriteEngine on
Rewriterule ^wp-content/uploads/(.*)$ http://exampled28t1vkps.cloudfront.net/$1 [r=301,nc]
# 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
You’re missing the [L] flag, which prevents other rules from redirecting:
Rewriterule ^wp-content/uploads/(.*)$ http://exampled28t1vkps.cloudfront.net/$1 [r=301,nc,l]
I am working with a GoDaddy Hosted Wordpress website.
I have users that will attempt to go to <mywebsite.com>/jobs and I need them to be redirected to <mywebsite.com>/newpath/corporate-opportunities/.
I am under the impression that I can place rewrite rules in the .htaccess file that exists at the root of my GoDaddy Hosted installation. I have the following in place:
# 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
<IfModule mod_rewrite>
RewriteEngine on
RewriteRule http://<www.mywebsite.com>/jobs http://<www.mywebsite.com>/newpath/corporate-opportunities/ [R]
</IfModule>
The first set of rules (within the Wordpress Begin and End comments) is what is commonly put in place for the Wordpress 'permalink' URL rewrites so they are pretty. The rewrite rule after the Wordpress block is how I am attempting to do the redirection.
I am not able to get it to work.
You need to move your redirect rules above the WordPress rewriting ruleset, so that they are seen before-hand. Additionally, the RewriteRule pattern (the first part) is always the request URI, and not the fully-qualified URL - as you are working with one domain, you also do not need to use the fully-qualified URL in the substitution part. Lastly, you need the L flag to stop processing at that point.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^jobs/?$ /newpath/corporate-opportunities/ [R,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
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.
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.