New answers tagged

1

If the query string is irrelevant then it can simply be ignored. (You can't match the query string anyway with the RewriteRule directive.) Try the following in your root .htaccess file to redirect the request: RewriteEngine On RewriteRule ^index.php/path/some-path/some-subpath$ /category/? [L,R=301] In per-directory .htaccess files, the URL-path matched ...


2

as @w3dk mention in the comments, I had to add a R=301 in my .htaccess file. RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [R=301,L] </IfModule> I didn't try Goyllo's answer but I think it's a good one if you don't have access to the server.


0

This could be further simplified to: RewriteRule ^([\w-]+(/[\w-]+)?)/?$ /userviewproducts.php?category=$1 [L] RewriteRule ^([\w-]+/[\w-]+/[\w-]+)/?$ /viewbuyproduct.php?1=$1 [L] \w is shorthand for [A-Za-z0-9_]. The - (hyphen) does not need to be escaped when used at the start or end of the character class. The ? at the end makes the preceding slash ...


0

To redirect a request for /something%26else (or /something&else, since the ampersand does not need to be escaped in the URL-path) to /something%2526else (ie. /something%26else when decoded) then you could do something like: RewriteRule ^(something)&(else)$ /$1\%26$2 [R,L] The RewriteRule pattern matches against the %-decoded URL-path (ie. &, ...


1

Have a look at my answer (on Drupal.SE) to the question "How to use the Rules module to implement a custom redirect for an outdated URL?". I bet the solution described there (using the Rules module) also works for this case. As detailed in that answer: the "clue" to get this to work, is to use the Rules Event "Drupal is initializing". That will ensure that ...


1

Google Webmaster Tools has no option to set HTTPS as the preferred version. Google takes this automatically from your canonical link tag. <link rel="canonical" href="https://example.com/"> So whenever the Google spider sees this line in your head section, Google automatically indexes the HTTPS version of your site. Nowadays, Google indexes HTTPS ...


2

Facebook would have been using the image URL as specified in the open graph tags. Since (by the sounds of it) the URL structure wasn't actually changed in WP (only in .htaccess) then this would have contained the /blog subdirectory in the URL. But then presumably you had to make an exception in .htaccess for the /blog/wp-content/uploads/ directory, or was FB ...


1

I tried doing this with a symlink, and it failed. After closetnoc also suggested I could use a symlink, I looked at it further. What worked was the following command (using SSH, at [~/public_html]#): mkdir blog mkdir /blog/wp-content ln -s ~/public_html/wp-content/uploads ~/public_html/blog/wp-content/uploads I would still like to know the correct way to ...


4

You are using the ^ and $ (anchors in regex speak) because you are matching the whole URL, which is what most people want to do, so this is the most common example you see. If you omit the ^ and/or $ anchors then you are only going to be matching part of the URL. eg. anything$ is going to match "anything" at the end of the URL - this could match too many ...



Top 50 recent answers are included