I have the rewrite ruls in .htaccess file under /var/www in my ubuntu10.4 server like below, When the url appears to be http://127.0.0.1/doc/view, the webpage shows "The requested URL /doc/view was not found on this server", and then I check the apach log, it logs "File does not exist: /usr/share/doc/view", so apprently apache redirect the /doc/view to /usr/share/doc/view. I don't know what it is going on here, can anybody help? thanks for help.
Options +FollowSymLinks
IndexIgnore */*
<IfModule mod_rewrite.c>
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>
Apache's default config on many distributions makes it so you can go to http://localhost/doc/to read the Apache documentation. You can edit this out in your httpd.conf or apache2.conf file if you need to use /doc for your own URLs.
Related
when trying to access my site glinks.tk I'm redirected to the configuration automatically, but when transferring my site to a VPS Wemin with Virtual Host I got problems, I put the files correctly but upon access I get the following message "The requested URL/install/index was not found on this server. " I've tried everything but I do not know how to solve it, the script I use is the Mighty URL Shortener and it uses two .htaccess one in the root and one in the webroot folder.
.htaccess from root:
DirectoryIndex index.php
# No directory listings
IndexIgnore *
<IfModule mod_rewrite.c>
RewriteEngine on
# Uncomment the following line if your webserver's URL is not directly related to physical file paths.
# Also uncomment it if you are on 1&1 hosting
#RewriteBase /
# Comment the following line if you have not a .well-known directory in the root folder.
RewriteRule ^(\.well-known/.*)$ $1 [L]
RewriteRule ^$ /var/www/glinks/webroot/ [L]
RewriteRule (.*) /var/www/glinks/webroot/$1 [L]
</IfModule>
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php5_module>
</IfModule>
# END cPanel-generated php ini directives, do not edit
<Files 403.shtml>
order allow,deny
allow from all
</Files>
.htaccess from webroot:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
What I'm trying to do is to enable a 'dry' version of url rewriting in Apache only to check if it is working and actually do not rewrite anything yet.
The simplest .htaccess that I came up with is:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
But this still doesn't work. All files, all paths I'm trying to request, no matter if they exist or not return 403 Forbidden
What I need is any example htaccess that has redirection inside that must work, that is allow access to all existing files and folders and do it's job only when the file requested doesn't exit.
The problem was that I've not added these lines:
Options +SymLinksIfOwnerMatch
or
Options +FollowSymlinks
I tried for the first time the Laravel Framework on my VPS.
In a folder where I have a other project folder (without any access problem) I create a project with "laravel new Test"
I changed the permission on "storage" and "bootstrap/cache".
Now I go to the page and...
"/Test/" => returns 403 Forbid
"/Test/index.php" => returns 404 Not Found
The mod_rewrite is enabled.
I set "AllowOverdrive All" to the main folder.
the .htaccess in the Test/public is the default one and i tried to change it to:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Restart httpd. restart all the vps... nothing changed...
What I miss?
The default documentRoot for access the content is in the folder /public
So you can access with www.example.com/public/
You should change the default root for example.com to the public folder.
Here is my .htaccess:
<Files.htaccess>
order allow,deny
</Files>
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(\w+)$ ./redirect.php?url_token=$1
My script's logic:
My script is not in the root of the website, it's in a folder (ex: www.mywebsite.com/script/). I have the .htaccess file in this folder.
The PHP script gets that url_token value and processes it, it is working well, i've tested it.
But when I use this .htaccess file and I try to access an URL like www.mywebsite.com/script/fa34d where fa34d is a random generated code, I get:
Error 500 on XAMPP and Access Forbidden on another online host.
What can be the problem?
I've already spent more time with this than the rest of the script.
You're likely creating a loop or you're redirecting to a file outside of your document root. If the folder accessed as the root is that same as what displays as www.mywebsite.com then you can set RewriteBase / in your access file. Remember all .htaccess files work together and also work with your VirtualHosts directives on the server.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\w+)$ /redirect.php?url_token=$1
You just need to add this line to hide your directory from http request in your .htaccess file
Options -Indexes
Enjoy!!
I have a domain (let the name be) mydomain.com.
I added a subdomain, sub.mydomain.com. (It's an other site, the two sites don't have anything to do with each other)
I have mapped the subdomain (with godaddy.com's tool) to /sub directory. It works well with static file paths, ex. http://sub.mydomain.com/js/script.js.php.
However, I would like to be able to use the rewrite module to get http://sub.mydomain.com/js/script.js
My .htaccess files:
.htaccess in the root directory:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub.mydomain.com$
RewriteRule ^.*$ http://mydomain.com/sub%{REQUEST_URI} [L,P]
.htaccess in the /sub directory:
RewriteEngine on
RewriteRule ^js/script\.js$ js/script.js.php [L]
(I tried adding RewriteBase /sub/, I didn't succeed).
It seems as if Apache didn't notice the /sub's .htaccess
How can I get the rewrite work on the subdomain's paths?
SOLVED!
After a long, exhausting debugging and googling I found an Apache setting that made the trouble:
I added Options -MultiViews and voilá, it works!
/////////////////////////////////////////////
Now my configuration:
-no .htaccess in the root.
-.htaccess in the root/sub:
DirectoryIndex site/index.php
Options -MultiViews
RewriteEngine on
RewriteRule ^site/js/script.js$ /site/js/script.js.php [L]