freakystreakefc
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Rewriting Custom page with .htaccessI’ve tried various suggestions off other forums and I can actually remove the page name from the URL but it takes me to a ‘page not found’ screen. By placing the ‘page-name’ back in the url then the final page is displayed.
I will explain my problem a little more.
I have a dynamic php page which I am linking to my custom WordPress (page name is ‘deltown’) page. Within this url I am passing two variables so that my ‘deltown’ page can get values from a table in the database.
Currently my url from the .php page to my wordpress ‘deltown’ page is:
example.com/deltown/value1/value2.htmlIn my template functions.php page I have added this set of functions to redirect to the ‘deltown’ page from my php page:
function custom_rewrite_tag() { add_rewrite_tag('%cid%', '([^&]+)'); add_rewrite_tag('%town%', '([^&]+)'); } add_action('init', 'custom_rewrite_tag', 10, 0); function custom_rewrite_rule() { add_rewrite_rule('^deltown/([^/]*)/([^/]*)/?','index.php?page_id=3090&cid=$matches[1]&town=$matches[2]','top'); } add_action('init', 'custom_rewrite_rule', 10, 0);My permalink for the custom page is:
example.com/deltown
and I have no page title set.In my .htaccess file I have this:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^deltown/(.*) /$1.html [R=301,L] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPressI have tried this line RewriteRule ^deltown/(.*) /$1.html [R=302,L] both inside my WordPress block and at the top of the file, outside the Worpress block. This works and produces a url of example.com/value1/value2.html but takes me to a ‘page not found’ page. How can I get the rewritten url to my custom page without ‘deltown’ in the url? Can this even be done?
The reason why I need the url this way is because we are moving our website from Prestashop over to WordPress/Woocommcerce and we have a few thousand indexed pages in google and don’t want to loose them. If I can get this url to write as I need then the move across platform should be a lot easier
- This reply was modified 7 years, 10 months ago by freakystreakefc.
- This reply was modified 7 years, 10 months ago by freakystreakefc.
Forum: Fixing WordPress
In reply to: Rewriting Custom page with .htaccessSorry, note taken and understood