<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^read(.+)?$ /read.php?id=$1 [QSA,L]
RewriteRule ^chapter(.+)?$ /readchapter.php?id=$1 [QSA,L]
RewriteRule ^list(.+)?$ /list.php?id=$1 [QSA,L]
</IfModule>
Above is my htaccess file, I trying create a story reading website.
I trying to shorten example link of
http://read.mydomain.com/chapter/three_little_fox/
So when it query
/chapter/three_little_fox
It will actually load readchapter.php?id=three_little_fox
But when I try load the page
http://read.mydomain.com/chapter/three_little_fox/
It throws a Internal 500 error.
Thanks for helping
The current .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^chapter/([^/]*)$ readchapter.php?id=$1 [L]
</IfModule>
But the 404 error exist, my folder is this way
.htaccess
readchapter.php
index.php
Try this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^chapter/(.*)/?$ /readchapter.php?id=$1 [QSA,NC,L]
</IfModule>
RewriteCond (Rewrite Conditions) ensures that if the request is already for a file or directory, RewriteRule will be skipped.
This will work for you:
RewriteEngine On
RewriteRule ^chapter/([^/]*)$ /readchapter.php?id=$1 [L]
Related
I'm trying to hide URL id
from
http://localhost/download/view.php?s_id=T7bPo
to
http://localhost/download/view/T7bPo
ReWriteEngine On
RewriteRule ^view/([0-9]+) view.php?s_id=$1
I tried many lines of code like
RewriteRule ^view/([^/\.]+)?$ /view.php?s_id=$1 [L]
RewriteRule ^view/+?$ /view.php?s_id=$1 [NC,L]
But failed everytime
Error
Object Not Found
As you can see below
If your .htaccess file is in /download/ folder check this rule on top of your rules:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^view\/(.*)$ /view.php?s_id=$1 [L]
</IfModule>
If your .htaccess file is in / website root folder check this rule on top of your rules:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^download\/view\/(.*)$ /download/view.php?s_id=$1 [L]
</IfModule>
#remove php file extension-e.g. https://example.com/file.php will become https://example.com/file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
from https://www.plothost.com/kb/how-to-remove-php-html-extensions-with-htaccess/
I am trying to shorten my website url of a newly added page event like
mysite.com/asoebi/myevent instead of mysite.com/asoebi/index.php?event=myevent
but every time i try to change my .htaccess file it give an error
here is .htaccess code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^index/(\w+)$ ./index.php?event=$1
</IfModule>
You have to enable mod_rewrite in apache for this to work.
Put this one in the .htaccess file in the /public_html/asoebi/ folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /asoebi/
RewriteRule ^(.*)$ index.php?event=$1 [L]
</IfModule>
Also remove the last rewriterule from the main htaccess file you posted above
I've a folder named test, I can access it via http://domain.com/test. I'm trying to send every requests of http://domain.com/test/XXX (XXX = every thing) to a php file.
I used this in test/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test
RewriteRule ^(.*)$ /control.php?path=$1 [L]
</IfModule>
control.php is in test folder too. But it doesn't work, i don't know in which rule i did a mistake! now every http://domain.com/test/XXX requests shows a 404 not found page!
Try this code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ control.php?path=$1 [L]
</IfModule>
I'm having some issues with a Codeigniter app in a subfolder on my server along with a Wordpress install in the document root. If I hide the index.php of the Codeigniter URL with .htaccess
/codeigniter/.htaccess
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|user_guide|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
And get Wordpress to ignore /codeigniter with RewriteCond %{REQUEST_URI} !^/(codeigniter).*$
/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(codeigniter).*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Then navigate to www.mysite.com/codeigniter/my_controller/my_function, I get a 404 error No input file specified. I found here, that adding a ? after RewriteRule ^(.*)$ index.php solves the Codeiginiter 404 error.
/codeigniter/.htaccess
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
However I'm now getting a Wordpress 404 error, so it seems if I replace index.php with index.php? in /codeigniter/.htaccess, the Wordpress rewrite rule in /.htaccess, RewriteCond %{REQUEST_URI} !^/(codeigniter).*$ gets ignored. Is there a better way to handle this?
Thanks in advance!
The RewriteBase in the codeigniter directory should say /codeigniter/
RewriteBase /codeigniter
Otherwise the rewrite to index.php ends up going to wordpress' router.
I am having an issue with the .htaccess file on a justhost.com account. I recieve constant internal 500 errors and I have tried many different solutions around the web. Here is what my htaccess files look like:
ROOT HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
app/ HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
app/webroot/ HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
The issue is that I get this in the error log:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Ive tried setting the RewriteBase to / but it doesnt correct the issue.
You have to use Rewrite base in three .htaccess files. The one in the root directory which contain directories app , lib , plugin and vendor should look like
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
The app / htaccess should look like
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /app/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
And finally the app/webroot/htaccess should look like
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /app/webroot
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
If your lib is not in the root folder you will have to also the change the values in core.php to map it to relevant address. For that you can check out the advanced installation in the cook book.
Check your file permission.
Switch off your htacess file and write echo 1;exit; index.php and check weather it shows or not.