Cleaning URL using .htaccess - .htaccess

From This:
crunchpaper.com/jlpt/form/try_question.php
To This:
crunchpaper.com/jlpt/try_question/
I try this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^try_question$ /try_question.php/$1 [NC,QSA]
But it's not working.
I want to clean the URL above.
Please help me. Thanks

This rule should work :
RewriteRule ^jlpt/form/try_question\.php$ jlpt/try_question/ [L]

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^jlpt/form/try_question\.php$ jlpt/try_question/ [L]
on /var/www/crunchpaper/jlpt
<Files ~ "^\.ht">
deny from all
</Files>
Options -Indexes
# ErrorPage
ErrorDocument 400 crunchpaper.com/
ErrorDocument 403 https://crunchpaper.com/
ErrorDocument 404 https://crunchpaper.com/
ErrorDocument 405 https://crunchpaper.com/
# DefaultPage
DirectoryIndex index.php index.html
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^crunchpaper.com\.com$
RewriteRule ^(.*)$ https://crunchpaper.com/$1 [R=301,L]
on /var/www/crunchpaper
Can you tell me what is wrong

Related

XCart 1.19.2.1 - enabling SSL

Can someone help me with this one please?
We have a XCart site running version 1.19.2.1 and we would like to force all traffic to HTTPS. The SSL certificate is installed and the .htaccess file looks like this:
DirectoryIndex home.php index.php index.html index.htm
# ErrorDocument 404 /404.php
# Show default error document for 404 errors caused by opening of image/media files.
<Files ~ "\.(gif|jpe?g|png|js|css|swf|ico)$">
ErrorDocument 404 default
ErrorDocument 401 default
# Clean URLs [[[
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(ww+\.)?domain\.com
RewriteRule ^(.*) http://www.domain.co.uk/$1 [R=301,L]
<IfModule mod_rewrite.c>
RewriteCond %{ENV:REDIRECT_STATUS} !^401$
RewriteCond %{REQUEST_URI} !^/(payment|admin|provider|partner)/
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|js|css|swf|php|ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ dispatcher.php [L]
</IfModule>
# /Clean URLs ]]]
RewriteEngine on
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
AddType application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
I have tried editing the file to redirect all traffic to HTTPS, I get a too many redirects error.
One example that I tried was replacing the entire contents of the .htaccess file with:
ErrorDocument 404 /index.php
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
rewritecond %{http_host} ^domain.co.uk [nc]
rewriterule ^(.*)$ https://www.domain.co.uk/$1 [r=301,nc]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domain.co.uk/$1 [R=301,L]
# RewriteRule ^([a-zA-Z0-9\-\%\s\_\.]+)(.htm)$ index.php?page=$1 [L]
##RewriteRule ^([a-zA-Z0-9\-\%\s\_\.]+)\.htm$ index.php?page=$1 [L]
DirectoryIndex index.php
#DirectoryIndex site_closed.html
RewriteEngine on
The above works fine on another XCart site but not this one. Again, I get the too many redirects error.
Anybody have any idea how I can fix it?
Kind regards
James
I had edited the htaccess file but I hadn't edited the https.php file as described here: https://help.x-cart.com/index.php?title=X-Cart:Configuring_HTTPS#Configure_the_HTTPS_server_in_X-Cart
All working now.

RewriteRule not working below

The below Rewrite Rules are not working
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^about/?$ /about.php [NC,L,QSA]
RewriteRule ^contact/?$ /contact.php [NC,L,QSA]
ErrorDocument 404 /404.php
But if I do this it works
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^about-us/?$ /about.php [NC,L,QSA]
RewriteRule ^contact-us/?$ /contact.php [NC,L,QSA]
ErrorDocument 404 /404.php
Any help greatly appreciated
Thank

htaccess 301 redirect DIrectory show file on file

I help how setting my htaccess if i want
redirect if youser visit directory
example.com/data/ need redirect on example.com/404
if user visit file
example.com/data/myfile.pdf show the file or download
Have this rule inside /data/.htaccess:
RewriteEngine On
RewriteOptions inherit
RewriteRule ^/?$ /404 [L,NC,R=301]
that my final configuration and work great
ErrorDocument 404 /index.php
ErrorDocument 403 /error/403
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
</IfModule>

URL Rewrite not working

This is my htacces file content. Its not working. Please help me guys...
DirectoryIndex index.php
Options -Indexes
RewriteEngine on
RewriteBase /shop/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteRule ^jeans-shirt/?$ /index.php?index/indexproducts/jeans-shirt/c695b64e4b38d8004f7c9b970ecbd104 [QSA,NC,L]
ErrorDocument 404 404.html
try this:
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>

ErrorDocument 404 not working with routing

I tried using this code on .htacces to have my own custom 404 on my page,.
ErrorDocument 404 http://mysite.com/404.shtml
when i visit the page that does not exist on the site. it must show something like this
but this is the one it shows
here is my complete htaccess
<files .htaccess>
order allow,deny
deny from all
</files>
php_value memory_limit 170M
RewriteEngine on
Options +FollowSymlinks
Options -Indexes
RewriteCond %{REQUEST_URI} (.+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
AddDefaultCharset utf-8
RewriteRule (.*) index.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.mysite.com.*$ [NC]
RewriteRule ^(.*)$ http://mysite.com%{REQUEST_URI} [L,R=301]
ErrorDocument 404 http://mysite.com/404.shtml
The location of my htaccess is located along with the 404.shtml and the index.php of the site
Removing this code would fix the problem. How can i make it work with routing.
RewriteCond %{REQUEST_URI} (.+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
AddDefaultCharset utf-8
RewriteRule (.*) index.php
Instead of referencing the entire url with ErrorDocument 404 http://mysite.com/404.shtml, name the document relative to your web root. In this case, /404.shtml.
Use these codes in your .htaccess for capture 404 error pages.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /404.html [L]
</IfModule>
Now your all 404 requests will goto /404.html. You can also use /404.php to code more dynamically. Also make sure that rewrite module is enabled in your apache.

Resources