New answers tagged

0

You can do that via .htaccess file. This file is used by Apache WebServer to read the configuration and directives, then it applies these directives to directory or subdirectory level (Depends on where you placed your .htaccess file). and the best part of that file is: If there is any error in .htaccess file, you get the internal server ...


2

You can have clean URLs with the following step. Install the wiki into http://localhost/w and NOT into http://localhost/wiki then Modify the following in LocalSettings.php after you have set it up: $wgArticlePath = "/wiki/$1"; In the ROOT directory place the following .htaccess file: RewriteEngine on ## uncomment this rule if you want to redirect to ...


1

The important thing is to place your external redirects before the WordPress internal rewrites (as Mike suggests in his answer). The WordPress rewrites are a "catch all" and rewrite everything. So if you place any rewrites/redirects after the WordPress stuff they will simply be ignored. RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteRule ^/?$ ...


3

# Use PHP5.4 as default # Changed PHP handler from application/x-httpd-php54 to application/x-httpd-phpbeta on Thu Dec 17 16:50:26 MST 2015. AddHandler application/x-httpd-phpbeta .php # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # Insert redirect based rewrites here. # Example: RewriteRule ^redirectme$ ...


0

RewriteRule ^([^/]*)/([^/]*)\.html$ song_in.php?album_id=$1&song_id=$2 [QSA,L] RewriteRule ^([^/]*)/([^/]*)\.html$ video_in.php?album_id=$1&video_id=$2 [QSA,L] You have a conflict with the last two directives. You are using the same pattern for both, so all these requests are going to song_in.php. The second (video_in.php) directive is never ...


2

and I want my link to be: http://example.com/shaandaar/kinna_sona.html shaandaar and kinna_sona are the slugs in my database. What should I write in my .htaccess file? This is the best way: RewriteEngine On RewriteRule ^([^/]+)/([^/]+)\.html$ /video_in.php?firstslug=$1&secondslug=$2 [L] In the RewriteRule, the ^ starts the matching. This: ...


0

Unless I'm mistaken, this should be along the lines what you're looking for: RewriteEngine On Options +FollowSyminks RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC] RewriteRule ^(.*)$ http://my-new-domain.com/$1 [NC,L] If you're wanting to keep the URL the same, there's no need for a R=302 flag, as it ...


1

For the HTML files, you can't have it both ways. The only way for Varnish to always show HTML files if they've changed would be to check every time (=cache miss), at which point you've not gained anything by using it. If your site changes very frequently, setting a short cache time like you have is probably the best you can do (although 3 seconds might be a ...


1

As far as I know the proxy target in mod_rewrite is simply a front-end to mod_proxy and the ProxyPreserveHost is the only directive to configure that behaviour. So without access to the main server config or VirtualHost config your indeed without luck. You might be lucky and your old hosting provider may already resolve your site to the new ip-address; ...


3

After some trys and searches I got it working using: RewriteCond %{DOCUMENT_ROOT}/$2 -f [OR] RewriteCond %{DOCUMENT_ROOT}/$2 -d RewriteRule ^([a-z]{2})/(.+)$ /$2 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L]


0

I once went for a solution which was simple, but effective: // You place this in your index.php session_start(); $_SESSION['is_user'] = true; // And this in your download.php: session_start(); if( isset($_SESSION['is_user']) ){ // Download magic here } A crawler often doesn't set a session, and for those that do often don't store it to the next url.


1

The rewrite loop is actually caused by rules later in your script: RewriteRule ^(en|it)/(.*) $2?lang=$1 [QSA] RewriteRule ^([^/]+)$ index.php?op=$1 [L,NS,QSA] index.php Having redirected the user to /en/ (with the Accept-Language rules), the first directive here rewrites the request back to ?lang=en (no URL-path) but the second directive then fails to ...


2

This answer comes from memory. If I'm 100% correct with the syntax, you'll want to replaced your 4 commented out lines of code with: RewriteCond %{REQUEST_URI} !^/en(.*)$ RewriteCond %{HTTP:Accept-Language} ^en [NC] RewriteRule ^$ https://www.example.com/en/ [L,R=301] RewriteCond %{REQUEST_URI} !^/it(.*)$ RewriteCond %{HTTP:Accept-Language} ^it [NC] ...


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

www.example.com will need replacing with your real URL. You could also try blocking the other URL's using robots.txt


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 ...


4

SOLVED! Thanks to you guys. Solution: # Turn Rewrite Engine On RewriteEngine on # Set the base to /games/ so we need not include it in the rules RewriteBase /games/ #Rewrite for achilles.php?games_path=xxxxxxxxxx.yyy&category_id=zzz RewriteRule ^([0-9a-zA-Z_-]+)/([0-9]+) $1.php?games_path=$1.swf&category_id=$2 [NC,L] ...


2

Try this if you have rewrite module installed: RewriteEngine On RewriteCond %{REQUEST_URI} ^(.*)wp-login.php$ RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx$ RewriteRule ^(.*)$ - [R=403,L] replace the xxx's with each octet of your IP address. For example, if your IP address is 111.222.333.444, then replace RewriteCond %{REMOTE_ADDR} ...


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 ...


2

I have: http://funkygames.co/games/achilles.php?games_path=achilles.swf&category_id=1 I want: http://funkygames.co/games/achilles/achilles/1 or even better: funkygames.co/games/achilles/1 (if that's possible) Try this: RewriteRule ^games/achilles/(.*)/([0-9]+)$ /games/achilles.php?games_path=$1.swf&category_id=$2 [NC,L] And if the game ...


1

Solved it! It's important to use Alias and Require all granted in httpd.conf! The httpd.conf file: This is the configuration of the Apache Sever 2.4! #### Wikibase (BETA) <VirtualHost *> ServerName wikibase.isc ServerAlias wikibase.isc ServerAdmin SuriyaaKudoIsc@users.noreply.github.com DocumentRoot ...



Top 50 recent answers are included