Here are my rewrite script (.htaccess)
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(action|ajax|api|uploads)(.*)$ - [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./index.php
Now I have the url: http://domain.tld/uploads/users/1/pictures/1443563069.jpg
The picture exist, but i can't load it. Is something with my rewrite rule not ok?
Try this code in root .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} /(action|ajax|api|uploads) [NC]
RewriteRule ^ - [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^ index.php [L]
Using %{THE_REQUEST} because REQUEST_URI changes to /index.php in your last rule.
Related
Stay On multi Url htaccess https://example.com/**toko**/login and on click stay https://example.com/**toko**/home....
please help me, because I don't really understand and explore htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /modchan
#RewriteRule ^([0-9]+)$ ?x=$1
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.tld$ [NC]
RewriteRule ^(.*)$ /public/$1 [L]
#RewriteRule ^ index.php [L]
#RewriteRule ^(/)?$ public/index.php [L]
</IfModule>
I'm trying to make www.site.com/web/name to be understood as www.site.com/web?system=name (without the change in URL)
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ $1?system=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ $1?system=$2
.htacceess is located in /web.
This doesn't do anything! Where is my mistake?
You may use these rules in web/.htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L,NE]
RewriteRule ^([\w-]+)/?$ ?system=$1 [L,QSA]
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
RewriteRule ^tags tags.php [L,NC]
</IfModule>
i want to add new page .but write page not found. why? please help me.
RewriteRule ^tags tags.php [L,NC] // i want this www.example.com/tags open tags.php ?
You need to reorder your htaccess rules like this :
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteRule ^tags/?$ tags.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
</IfModule>
The problem is that, your rule
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
Rewrites any request (not a true file/dir) to index.php. since /tags is not an existent file on your directory, so a request for http://example.com/tags was being rewritten to /index.php and the last rule(s) never executed.
I know there are some questions like this out there but the solutions are not helpful for me.
I´m using htaccess to redirect to the index.php if the request file isn´t defined (code above).
I´d like to add a code-line that if the user requests for example:
http://www.example.com/test/index.php
he will redirect to
http://www.example.com/test/
but internal it will redirect to the index.php.
Is there a way to extend my code so that it works like I want it to?
# Add Slash
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
# Redirect to index.php if the following sites were not match
RewriteBase /
RewriteCond %{REQUEST_URI} \.(php|sql|tgz|gz|txt|ttf|TTF|log|txt|ini|html|xml|xhtml|htm)$
RewriteCond %{REQUEST_URI} !^/index.php$
RewriteCond %{REQUEST_URI} !^/phpinfo.php$
RewriteCond %{REQUEST_URI} !^/out.php$
RewriteCond %{REQUEST_URI} !^/sitemap[^0-9]*\.xml$
RewriteCond %{REQUEST_URI} !^/robots.txt$
RewriteRule ^(.*)$ /index.php?dir=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^(.*)$ /index.php?dir=$1 [QSA,L]
Complete code:
DirectoryIndex index.php index.html
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# Take off index.php
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ http://%{HTTP_HOST}%1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} \.(php|sql|tgz|gz|txt|ttf|TTF|log|txt|ini|html|xml|xhtml|htm)$
RewriteCond %{REQUEST_URI} !^/((index|phpinfo|out)\.php|robots\.txt|sitemap[^0-9]*\.xml)$
RewriteRule ^(.*)$ /index.php?dir=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?dir=$1 [QSA,L]
# Add Slash for non-files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
What is wrong with this line
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?query=$1 [L]
I'm try rewrite links from
http://mysite.com/index.php?query=2012
to
http://mysite.com/2012
But i have 500 Internal Server Error
Also here is the content from my htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^software$ index.php?type=app
RewriteRule ^movies$ index.php?type=movie
RewriteRule ^games$ index.php?type=game
RewriteRule ^music$ index.php?type=music
RewriteRule ^other$ index.php?type=other
RewriteRule ^tv$ index.php?type=tv-show
RewriteRule ^ebooks$ index.php?type=ebooks
RewriteRule ^(.*)-(\d+)\.html$ download.php?id=$2 [L,NC]
RewriteRule ^site/([^/]*)$ /index.php?site=$1 [L]
RewriteRule ^([^/]*)$ /index.php?query=$1 [L]
Replace this rule:
RewriteRule ^([^/]*)$ /index.php?query=$1 [L]
with this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]*)/?$ index.php?query=$1 [L,QSA]