I succeeded to use .htaccess with mod_rewrite for my first domain name.
I try to use it for a second domaine name, and I have for result "Internal Server Error".
However, I put the same files on their server, and they have the same configuration.
The content of the .htaccess file :
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
Where can the problem come from ?
Best regards,
I found the solution, it's a problem with the encodage.
Getting Error 500 with this .htaccess on Linux, works fine on Windows
Related
I have link like this: http://site.crm.int/project_discussions/test
I need redirect it to : http://site.crm.int/project_discussions/index.html?url=test
Text 'test' is changable. Can be for example 'december', 'meetting01' etc.
I tried it in my .htaccess:
RewriteRule ^\/project_discussions/(.*)$ \/project_discussions\/index.html?url=%1 [L]
But have 404 error.
Also tried this:
RewriteCond %{REQUEST_URI} ^/project_discussions/(.*) [NC, L]
RewriteRule ^(.*)$ /index\.html?url=$1 [L,NC]
And have 'Internal Server Error'
How can i fix it? thanks
With your shown samples, please try following .htaccess rules file. Make sure .htaccess file and folder project_discussions are residing in same root folder. Also your index.php OR index.html file should be inside your project_discussions folder.
Make sure to clear your browser cache before testing your URLs.
Also I have fixed your previous rule for handling internal rewrites.
RewriteEngine On
RewriteBase /project_discussions/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/?$ $1/index.html?url=$2 [R=301,NE,QSA,L]
Getting 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 at webmaster#api.example.com.au to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
I pushed live codeigniter project, I updated .htaccess , database file, config file.
.htaccess file contains following code
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|css|js|images|robots\.txt)
RewriteRule ^(.*)$ index.php?$1 [L]
Options -Indexes
The Codeigniter project is inside api.websiteName.com folder and it is not in public_html, if i remove the index.php and htccess file and upload "index.html" file for testing purpose , then index.html works fine but when I upload index.php and .htaccess files back , it says Internal server error 500, There are many answers for same question, I followed answers and did update .htaccess file but nothing works. Folder permissions set as 755 but still getting same error. Any help would be much appreciated.
PHP verison is higher than 5.6
You can try this .htaccess file in your code.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin "*"
</IfModule>
<IfModule mod_env.c>
SetEnv CI_ENV development
</IfModule>
I hope it will help you..
Need help with litespeed web server .htaccess rules.
http://example.com/temp/home.php is existing URL, but now what we need to rewrite is mentioned below:
http://example.com/temp.php?redirect=home.php
And our Existing .htaccess code is also given below.
RewriteEngine on<br/>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^temp/(.*)$ temp.php?redirect=$1 [QSA,L]
But I don't know the issue, this rewrite still not working and shows 404 error because temp/home.php does not exist.
These rules are working perfectly with Apache server, but not working with Litespeed
For reference:
https://htaccess.madewithlove.be?share=d15d3bca-6974-5682-902a-823c1a63e2b7
Thanks in advance.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^temp/(.*)$ temp.php?redirect=$1 [QSA,L]
The above code will serve the content of temp.php?redirect=home.php.
As a test I created temp.php in the root directory of a domain, with the content:
<?php
var_dump($_GET);
The result when accessing /temp/home.php is:
array(1) {
["redirect"]=>
string(8) "home.php"
}
This is tested on LiteSpeed Web Server 5.3.4 and 5.3.5.
Hi guys experimenting with .htaccess with XAMPP on my localhost, I have checked with phpinfo() if mod_rewrite is loaded and it is, so that shouldnt be the problem..
This is my .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA, L]
and this is the error it gives on every page
SERVER ERROR
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
Whats wrong with my htaccess or XAMPP? :)
$url was empty, make sure you echo out !
I have this htaccess setup on my clients site, they use godaddy
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]
it worked fine on my MAMP but does not seem to work on the server
they have setup a subdomain like demo.example.com and the htaccess exists in the demo folder but I get 404 trying to get to page like demo.example.com/test but demo.example.com/test.php works fine so this tells me the htaccess is not work. does anyone know what I need to do to make this work ?
Try:
1) Add this line into your .htaccess: Options +FollowSymlinks
2) Add leading slash before $1, e.g. RewriteRule ^(.*)$ /$1.php [L,QSA]
P.S. There are some "rumours" that GoDaddy may not pick up changes in .htaccess file straight away.
I would also suggest to define custom 404 error handler (simple PHP script) that may help with debugging this (put this line into your .htaccess):
ErrorDocument 404 /404.php
404.php (as simple as this)
<?php
Echo "404\n";
phpinfo(INFO_VARIABLES);
The details there may help identify the issue.
UPDATE:
We have a domain name & hosting that we do not use which is about to expire. So I have logged in and tested these rules myself. Got it working straight away. Here is the setup I have:
Apache/1.3.33
Hosting Configuration: 2.1
PHP 5.x (did not bothered to check exact version)
Data Center: US Regional
.htaccess was already present and had only 1 line 9possibly left over from the site that was there originally):
addhandler x-httpd-php5 .phtml
These lines were added to .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ /$1.php [L,QSA]
I have created simple php file to check if it works. Called it echo.php. Then I have tried these URLs:
http://www.example.com/abcd -- saw error page (as expected)
http://www.example.com/echo -- saw my page -- echo.php (as expected)
The full physical path to the echo.php is: /home/content/b/u/y/buyxxxxxxx/html/echo.php; ftp/website root is /home/content/b/u/y/buyxxxxxxx/html/
Try this simple setup. DO not do anything complex until you solve this issue.
This is right way of play with .htaccess on godaddy
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ /$1.php [L,QSA]
This answer on Stack Overflow might help you aswell:
Add this:
Options +FollowSymLinks -MultiViews -Indexes
at the very top and give it a try.