htaccess internal server error rewrite not working - .htaccess

I have a pretty simple .htaccess file that is causing a 500 Internal Server Error but I don't know why. I am using WAMP with virtual host wdc.test, my root folder is C:\wdc, and my www folder is C:\wdc\www, links that look like this href="wdc.test/title" come up with the error when I know that it should be pulling up the index file in www
my .htaccess file looks like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /www/index.php [L,QSA]
thanks

It is most likely due to the reason that your DocumentRoot points to C:\wdc\www instead.
If that is indeed the case use this rule in site root .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

Related

Error on rewrite rule inside subdirectory

When my website was inside the root directory of my hosting, everything works find. However, I had to move my website files to a subdirectory.
Old:
/www/*
Current:
/www/websites/example
Now, I can visit the homepage of my website, but I get error when I visit other pages of my site.
example.com/1234/title_of_url -> example.com/index.php?qa-rewrite=1234/title_of_url
But when I visit that sample page, i get the following error.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Here is my .htaccess file:
RewriteEngine On
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]
Note: I have moved the file to my /www/ dir and it works fine. So I think I am missing to put websites/example somewhere in my .htaccess
Use this rule in site root .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/websites/ [NC]
RewriteRule .* websites/example/$0 [L]
Then use this code in websites/example/.htaccess:
RewriteEngine On
RewriteBase /websites/example/
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!index\.php$).*$ index.php?qa-rewrite=$0 [NC,L,QSA]

Codeigniter deploy index.php show 404 error

I just deploy my codeigniter project into hosting server. I got this problem.
By right the link should work in this -> http://test.com/quiz/test
When I deploy I need to key this then can work.
http://test.com/quiz/index.php/test
This my server hierarchy
public_html
|-css
|-js
|-index.php
|-quiz
|---application
|---system
|---index.php
|---....
|---.htaccess
This is my htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]
Is that correct?
Try this in your htaccess, this works for me:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Also keep your htaccess inside quiz folder not in application folder.
Change the file names to First letter Caps and class name too.
ex: mas_unit_ctrl change to Mas_unit_ctrl

Code igniter htaccess pointing to a folder while removing index.php and adding www

As the title says, I am using Code Igniter, need to point to a folder on godaddy hosting account, while removing index.php and adding www.
My current settings work for the main page only, also all the css and js files get included. However, none of the internal links work and i get 500 internal server error.
all the current settings:
In the domain settings, it is pointing to a folder on my hosting, working correctly since the main site loads.
config.php
$config['base_url'] = 'http://www.example.com';
$config['index_page'] = '';
htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
Edit: Managed to solve it, all that was missing was this line
RewriteBase /
i am not sure whether it will work for you or not but i am using it and its working fine for me.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
just paste the code in your root directory .htaccess file. Please let me know the status.

htaccess - Redirect one folder to another internally

I would like to redirect all no-files and no-directories of one folder to another. The .htaccess should be on root (http://example.com).
Example:
http://example.com/admin/core/file.php - Does not exists. So, redirect (internally) to http://example.com/adminhide/core/file.php
http://example.com/admin/index.php - Exists. So, don't do anything..
I tried to create the code, but I'm having an 500 Internal Server Error:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/admin/$
RewriteRule (.*)$ /adminhide/$1 [L]

htaccess for subdomain

Need help with .htaccess
I have website on my localhost with this .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ website/index.php/$1 [L]
Now i want to move the site to subdomain.domain.com
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://subdomain.domain.com/index.php/$1 [L]
I chaged the url but this doesn'n work maybe because this is subdomain i don't know
hosting details:
# Subdomain Name Path [?]
1 subdomain.domain.com /home/www/subdomain.domain.com
my urls are like this
http://website/index.php/contact
with this htaccess i can use
http://website/contact
When i moved the site to the subdomain i can use http://subdomain.website/index.php/contact but when try http://subdomain.website/contact gives me error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Try with this one, it should work for all domains localhost as well as server.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Make sure "rewrite_engine = on" on server.

Resources