I would like to make a simple URL rewrite but can not succeed... Here is what I have:
I have 3 websites on the same hosting.
www.websiteAAA.com - a regular website, located in '/website-AAA-folder' folder
www.websiteBBB.com - a regular website, located in '/website-BBB-folder' folder
www.websiteCCC-Wordpress.com - a Wordpress website, , located in '/website-CCC-Wordpress-folder' folder
I order to redirect the requests to the correct domain-filder I have an .htaccess file in the main directory:
Options +SymLinksIfOwnerMatch AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
#redirect to the correct folder
RewriteCond %{HTTP_HOST} websiteAAA.com$ [NC]
RewriteCond %{REQUEST_URI} !^/website-AAA-folder/.*$
RewriteRule ^(.*)$ /website-AAA-folder/$1 [L]
#redirect to the correct folder
RewriteCond %{HTTP_HOST} websiteBBB.com$ [NC]
RewriteCond %{REQUEST_URI} !^/website-BBB-folder/.*$
RewriteRule ^(.*)$ /website-BBB-folder/$1 [L]
#redirect to the correct folder
RewriteCond %{HTTP_HOST} websiteCCC-Wordpress.com$ [NC]
RewriteCond %{REQUEST_URI} !^/website-CCC-Wordpress-folder/.*$
RewriteRule ^(.*)$ /website-AAA-folder/$1 [L]
in /website-CCC-Wordpress-folder/ (where the wordpress site is), there is an additional .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I woulde like to rewite www.websiteCCC-Wordpress.com/aaa/ to www.websiteCCC-Wordpress.com/?id=2&someugleurl=e&blabla=1
I add this line to my .htaccess file that is in the root folder:
RewriteRule ^(aaa)$ ?id=2&someugleurl=e&blabla=1 [L]
However, that does not work.
Please advice.
Thanks
Figured it out
You have to put the line
RewriteRule ^(aaa)$ ?id=2&someugleurl=e&blabla=1 [L]
to be first in the htaccess file in wordpress
RewriteRule ^(aaa)$ ?id=2&someugleurl=e&blabla=1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Related
I need to let an external software collect a zip file from my Wordpress site. The site is converted to https, but the software asks for the HTTP version of the file, http://www.example.com/foldername/grunfil.zip
So can I add something in .htaccess to make that file only http?
Here is my current .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I tried this, but it creates an endless loop:
redirect 301 /foldername/grunfil.zip http://www.example.com/foldername/grunfil.zip
Check this rule, maybe it help.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^foldername\/grunfil\.zip
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I have uploaded my project to shared hosting but the the css and js files fail to download.
I'm using AdminLte theme, the folder of AdminLte is located in public folder
The contents of .htaccess file(public/.htaccess)
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
and this is the .htaccess file that i made in project folder
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /public/$1
#RewriteRule ^ index.php [L]
RewriteRule ^(/)?$ public/index.php [L]
</IfModule>
The following errors occur:
My site ww.example.com runs WordPress in its root directory, meaning that any paths are redirected to the WordPress install to be evaluated. I also have an install of DokuWiki under www.example.com/path/to/wiki/, which similarly uses .htaccess to deliver wiki pages at paths like www.example.com/path/to/wiki/wikipage.
The file structure on the server stores all the non-WordPress content in a subdirectory called content, so the Dokuwiki install is actually located in content/path/to/wiki/.
Unfortunately, whilst www.example.com/path/to/wiki/ displays correctly, www.example.com/path/to/wiki/wikipage is clearly passed back to the top-level WordPress .htaccess and returns a 404 error.
What do I need in my .htaccess files to make this set-up work?
Example .htaccess files
Top-level WordPress .htaccess
# Rewrite to content directory
RewriteCond %{DOCUMENT_ROOT}/content/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/content/$1index.php -f [OR]
RewriteCond %{DOCUMENT_ROOT}/content/$1index.html -f
RewriteRule ^(.*)$ /content/$1 [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
DokuWiki .htaccess
RewriteEngine on
RewriteBase /path/to/wiki
RewriteRule ^_media/(.*) lib/exe/fetch.php?media=$1 [QSA,L]
RewriteRule ^_detail/(.*) lib/exe/detail.php?media=$1 [QSA,L]
RewriteRule ^_export/([^/]+)/(.*) doku.php?do=export_$1&id=$2 [QSA,L]
RewriteRule ^$ doku.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) doku.php?id=$1 [QSA,L]
I would think that all you need to do is omit the path to wiki and content directories from your .htaccess file in the root and include the path in the first rewriterule.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/content/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/content/$1index.php -f [OR]
RewriteCond %{DOCUMENT_ROOT}/content/$1index.html -f
RewriteRule ^(path/to/wiki/.+/?)$ /content/$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(path/to/wiki|content)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I'm hoping you guys can help me out. I want to rename my theme's CSS & JS path but I can't seem to figure it out.
For example:
I want to change:
http://cdn.(domain-name).com/wp-content/themes/smart-mag/style.css
to
http://cdn.(domain-name).com/style.css
& from:
http://cdn.(domain-name).com/wp-content/themes/smart-mag/js/bunyad-theme.js
to
http://cdn.(domain-name).com/js/bunyad-theme.js
etc, etc.
Here is what I tried in my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^wp-content/themes/smart-mag/screenshot\.png|readme\.html|license\.txt|wp-content/debug\.log|wp-includes/$ /nothing_404_404 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
RewriteCond %{REQUEST_URI} \.(css|js|jpe?g|gif|png|bmp)$
RewriteCond %{REQUEST_URI} !^/themes/smart-mag/
RewriteRule ^(.*) /themes/smart-mag/$1 [L]
</IfModule>
#END WordPress
That modified htaccess did nothing at all. What am I missing/doing wrong here?
You need to change the order of your rules. The wordpress rules route all requests to index.php, including your /style.css etc URLs. So you need to route those first.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.(css|js|jpe?g|gif|png|bmp)$
RewriteCond %{REQUEST_URI} !^/themes/smart-mag/
RewriteRule ^(.*) /themes/smart-mag/$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteRule ^wp-content/themes/smart-mag/screenshot\.png|readme\.html|license\.txt|wp-content/debug\.log|wp-includes/$ /nothing_404_404 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
</IfModule>
#END WordPress
I have a pretty standard WordPress .htaccess with the following URL rewrites
# 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
WordPress is installed in my domain root. I have some other scripts in subfolders, e.g. /opencart These subfolders contain their own .htaccess files.
Unfortunately, it seems that WordPress hijacks the rewrites for some of these scripts sometimes.
How can I ask mod_rewrite to ignore WordPress rules for rewrites when encountered with specific subfolders e.g. opencart and to use the rules defined in the .htaccess within these subfolders instead?
You may try replacing the complete WP rule-set with this one:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
# Include in the next line all folders to exclude
RewriteCond %{REQUEST_URI} !(folder1|folder2|folder3) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
In the .htaccess file in your site root, add the following ABOVE the WordPress .htaccess directives:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/subdirectoryname1/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/subdirectoryname2/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^/(folder1)/(.*) /folder1/$2 [R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L,R]
</IfModule>
# END WordPress