here is my .htaccess code
Options all -Indexes
<Files .htaccess>
order allow,deny
deny from all
</Files>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^thumb/(.*)$ thumb.php?imagePath=$1 [B]
</IfModule>
If i enter url as http://mydomain.com/thumb/image1.jpg then its passed to thumb.php?imagePath=image.1, and its working fine.
suppose if i enter url as http://mydomain.com/thumb/http://otherwebsite.com/images/image1.jpg
then its showing 404 error. Please help me to sort out this issue
And i used encodedurl too like this http://mydomain.com/thumb/http%3A%2F%2Fotherwebsite.com%2Fimages%2Fimage1.jpg
Same i got 404 Error. Please help me to sort out this.
To use a parameter with http:// you need to use capture the URI using THE_REQUEST variable. THE_REQUEST variable that represents original request received by Apache from your browser
Try this rule:
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{THE_REQUEST} \s/+thumb/(\S+) [NC]
RewriteRule ^ thumb.php?imagePath=%1 [B,L,NE]
Why have you add a / at the end of your rule ?
Try this :
Options all -Indexes
<Files .htaccess>
order allow,deny
deny from all
</Files>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^thumb/(.*)$ thumb.php?imagePath=$1 [B]
</IfModule>
Related
I am using polish CMS called Batflat, which .htaccess does not allow access to txt files. I only need to get access to robots.txt other txt files may no be accessible.
.htaccess content:
# Prevent directory listings
Options -Indexes
# Prevent visitors from viewing files directly
<FilesMatch "\.(sdb|md|html|txt)$">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</FilesMatch>
# URL rewrites
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(inc/|themes/|tmp/).*\.(php|html)$ - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>
I am not familiar with .htaccess - could you help me solve my problem?
Thank you
SK
I have received answer 5 line should be:
<FilesMatch "(\.(sdb|md|html|txt)|(?<!robots.txt))$">
Maybe it will solve someone problem.
Greets
SK
My front url is-
http://localhost/myProject/
admin url is -
http://localhost/myProject/admin
It works in windows but not works on Ubuntu.
It gives error "Not found".
What works in ubuntu -
The front page is working - http://localhost/myProject/
The admin login page is working if I add index.php in url like this -
http://localhost/myProject/index.php/admin
Not other pages are working
My .htaccess file contents-
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|themes)
RewriteRule ^(.*)$ /myProject/index.php/$1 [L]
My Apache's mod-rewrite module is on.
I was also following the similar issue in Centos, and I followed the below tutorial :
How to permit changes in the .htaccess file:
open httpd using ------------------> vi /etc/httpd/conf/httpd.conf
Once inside that file, find the following section, and change the line that says AllowOverride from None to All. The section should now look like this:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
After you save and exit that file, restart apache. .htacess files will now be available for all of your sites.
service httpd restart
Content of .htaccess file:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -Indexes
RewriteEngine on
# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
#RewriteBase /
# Restrict your site to only one domain
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|fonts|js|images|robots\.txt|css)
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
</IfModule>
#prevent access to htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
#disable directory browsing
Options All -Indexes
IndexIgnore *
This is a rule in htaccess file :
RewriteRule ^Serie-examens-([0-9]+)-([0-9]+)-([a-zA-Z]+)$ examens-list.php?idChapitre=$1&idTitre=$2 [L]
In href i've put this url :
href="<?php echo 'Serie-examens-'.$idChapitre.'-'.$idTitres[0].'-debuter');?>"
i've this error when i click in the link :
Not Found
The requested URL /SerieJava/Serie-examens-1-1-debuter was not found on this server.
I'm using wamp, and i test rewriting url without variables , it works
where is the error in the rule ?
The Full .htaccess file :
SetEnv REGISTER_GLOBALS 0
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options -Indexes
RewriteEngine On
RewriteBase /SerieJava/
RewriteRule ^Le-premier-chapitre chapitre1.php [L]
RewriteRule ^Serie-examens-([0-9]+)-([0-9]+)-([a-zA-Z]+)$ examenss-list.php?idChapitre=$1&idTitre=$2 [L]
thanks
You have a closing ) in the link php that should not be there:
href="<?php echo 'Serie-examens-'.$idChapitre.'-'.$idTitres[0].'-debuter');?>"
^ here
That probably leads to a php error that invalidates your link.
Edit: Also note that you are using this to rewrite:
RewriteRule ^Serie-examens-([0-9]+)-([0-9]+)-([a-zA-Z]+)$ examens-list.php?idChapitre=$1&idTitre=$2 [L]
The ^ denotes the start so if your path is /SerieJava/Serie-examen.... it will not be rewritten because it starts with /SerieJava/.
You should post the whole .htaccess file to see if that is the problem but it looks like it is.
This should be your /SerieJava/.htaccess:
SetEnv REGISTER_GLOBALS 0
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options -Indexes
RewriteEngine On
RewriteBase /SerieJava/
RewriteRule ^Le-premier-chapitre chapitre1.php [L,NC]
RewriteRule ^Serie-examens-([0-9]+)-([0-9]+) examens-list.php?idChapitre=$1&idTitre=$2 [L,QSA,NC]
Try adding a / to your rewrite rule:
RewriteEngine On
RewriteBase /SerieJava
RewriteRule ^/Serie-examens-([0-9]+)-([0-9]+)-([a-zA-Z]+)$ examens-list.php?idChapitre=$1&idTitre=$2 [L]
Notice the / after the ^ and before Serie
You may also try removing the carot from the rule:
RewriteEngine On
RewriteBase /SerieJava/
RewriteRule Serie-examens-([0-9]+)-([0-9]+)-([a-zA-Z]+)$ examens-list.php?idChapitre=$1&idTitre=$2 [L]
i am trying to figure ou ta rewrite rule to direct certain urls to to specific php file:
the file is watch.php
the urls are like this http://mysite/watch/193916/1/watch-skysports.html
i want to redirect this
http://mysite/watch.php?file=watch/193916/1/watch-skysports.html
my try in the htaccess file
Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule watch/(*)/(*)/(*).html match.php?file=$1 [L]
</IfModule>
but it doesnt work
nb:mod_rewrite is enabled
You don't have the right regex. The * isn't a wildcard, it's to indicate some number of characters. Try this instead:
Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(watch/[0-9]+/[0-9]+/.*\.html)$ /match.php?file=$1 [L]
</IfModule>
I want to have a user friendly url such as "http://localhost/Symfony/web/app_dev/" instead of "http://localhost/Symfony/web/app_dev.php/" . I have tried editing the htaccess but still does not work. My htaccess in the web dir is :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
I suppose it should have worked.. How can I make this work and what is the problem in the htaccess codes if any?
Try to add into your vhost configuration following lines:
<Directory "/path/to/docroot">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Try adding RewriteRule ^app_dev(.*)$ app_dev.php [QSA,L] before RewriteRule ^(.*)$ app.php [QSA,L].
You must enable the RewriteEngine in the apache configuration:
sudo a2enmodule rewrite
Regards,
Max