Pretty url index page - .htaccess

I only got the first pretty url working. I don't get the 2nd and 3rd working, they just show a messed up page (Styles not loaded) + it show wrong page
Here is my code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?tab=$1 [NC]
RewriteRule ^/ucp(.*)$ index.php?ucp&tab=$1 [NC]
RewriteRule ^/ucp(.*)$ index.php?ucp [NC,L]
.
Possible urls:
http://subdomain.domain.com/path2files/index.php?&tab=str
http://subdomain.domain.com/path2files/index.php?ucp
http://subdomain.domain.com/path2files/index.php?ucp&tab=str
How they should look like:
http://subdomain.domain.com/path2files/str
http://subdomain.domain.com/path2files/ucp
http://subdomain.domain.com/path2files/ucp/str

Try this:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /path2files/index\.php\?ucp&tab=(.*)\ HTTP
RewriteRule ^ /path2files/ucp/%2\? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^path2files/ucp/(.*)$ /path2files/index.php?ucp&tab=$1 [L]
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /path2files/index\.php\?ucp\ HTTP
RewriteRule ^ /path2files/ucp\? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^path2files/ucp$ /path2files/index.php?ucp [L]
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /path2files/index\.php\?&tab=(.*)\ HTTP
RewriteRule ^ /path2files/%2\? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^/ucp
RewriteRule ^path2files/(.*)$ /path2files/index.php?&tab=$1 [L]

Related

How to rewrite the website URL in .htaccess

is there a way to replace an url with the .htaccess like this:
http://website.com/file.php?watch=video
to this one:
http://website.com/file/watch/video
Tried with this,and haven't worked.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/watch/([\d]+)$ $1.php?watch=$2 [L]
My .htaccess file:
#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]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/watch/([\w-]+)$ $1.php?watch=$2 [L]
Have it this way:
RewriteEngine on
RewriteBase /test/
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /([\w-]+)\.php\?watch=([^\s&]+)\s [NC]
RewriteRule ^ %1/watch/%2? [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/watch/([\w-]+)$ $1.php?watch=$2 [L,QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

Redirect from sub.domain.co.id to https://sub.domain.co.id

Good day. I have a website called with sub.domain.co.id and now I want to redirect it to https://sub.domain.co.id.
I'm using codeigniter and this what i change in my .htaccess
Before .htaccess look like this
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
then I change it to ref(redirecting https://domain.com to https://www.domain.com)
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^http://. [NC]
RewriteRule ^ https://sub.domain.co.id%{REQUEST_URI} [R=301,L,NE]
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
but no help. the URL still use http. How can i achieve that?
try this and see. (index.php will removed too)
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^sub.domain.co.id [NC]
RewriteRule ^(.*)$ https://www.sub.domain.co.id/$1 [L,R=301]
didn't test. 95% Sure. Not the 100%

Htaccess for custom URL

I have URL site.com/page/ and have htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*[^/])$ $1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
But my CMS need for the search URL without slug, like site.com/search?query=
How to write the rule for custom URL?
You can make a rule to ignore /search URI:
RewriteEngine On
RewriteRule ^search/?$ - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*[^/])$ $1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Frog CMS htaccess diagnosis

I have a issue with Frog CMS, its the first time I use this CMS, is a client that uses this.
Scenario: I modified 1 redirection using a plugin called "Redirector" that destroyed the whole site!
Luckly, I found an htaccess from some months ago, that allows the site to work, but the redirections none of them works, the site works, but not the redirections, the main url rewriting for the site seems to be Ok, but the 301 redirects I need, dont work.
I cant figure out why this is happening, why this redirections dont work correctly, they dont conflict, but they dont do nothing! Can you advice on this ? Im looking forward uderstanding more about url rewritting and htaccess.
I cant use the plugin to generate redirections, because it destroyed the whole site. If there is a way to "reset" the url rewritting in this CMS it would be good, but I dont have cooperation form the developers of the site...
I appreciate any help to understand better what is wrong , why all the
RewriteRule ^site/services/immigration/ /services/immigration.html [L,R=301]
dont work!
### CMS-Generated Update August 1, 2013, 1:45 pm ###
#
# Setting Frog requirements
#
AddType text/x-component .htc
AddType video/ogg .ogm
AddType video/ogg .ogv
AddType video/ogg .ogg
AddType video/webm .webm
AddType video/mp4 .mp4
AddType video/x-m4v .m4v
AddType audio/webm .weba
AddDefaultCharset UTF-8
Options -Indexes -MultiViews +FollowSymLinks
DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !.local$ [NC]
RewriteCond %{HTTP_HOST} !.local$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^install/index.html$ install/index.php?rewrite=1 [L,QSA]
RewriteRule ^install/index.php$ install/index.php?rewrite=1 [L,QSA]
RewriteRule ^install/$ install/index.php?rewrite=1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA]
RewriteCond %{DOCUMENT_ROOT}/cache/index.html -f
RewriteRule ^$ /cache/index.html [L,QSA]
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteCond %{DOCUMENT_ROOT}/cache/%{REQUEST_URI} -f
RewriteRule ^(.*)$ /cache/$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^download/(.*)$ /downloads.php?THISPAGE=download.html&media=pdf&filename=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^private/(.*)$ /private.html?THISPAGE=private.html&userfile=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^mobile/search/(.*)$ mobile.html?THISPAGE=search.html&media=mobile&search=$1 [L,QSA]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME} !-l
#RewriteRule ^mobile/(.*)/process.html$ mobile.html?THISPAGE=$1&media=mobile&return=process [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^mobile/(.*)/success.html$ mobile.html?THISPAGE=$1&media=mobile&return=success [L,QSA]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^standard/search/(.*)$ standard.html?THISPAGE=search.html&media=standard&search=$1 [L,QSA]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME} !-l
#RewriteRule ^standard/(.*)/process.html$ standard.html?THISPAGE=$1&media=standard&return=process [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^standard/(.*)/success.html$ standard.html?THISPAGE=$1&media=standard&return=success [L,QSA]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME} !-l
#RewriteRule ^(.*)/process.html$ contact.html?THISPAGE=$1&return=process [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)/success.html$ contact.html?THISPAGE=$1&return=success [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^search/(.*)$ index.php?THISPAGE=search.html&search=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^proposal.html$ index.php?THISPAGE=$1&media=proposal [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^contrast/search/(.*)$ contrast.html?THISPAGE=search.html&search=$1&media=contrast [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^print/search/(.*)$ print.html?THISPAGE=search.html&search=$1&media=print [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^mobile/(.*)$ mobile.html?THISPAGE=$1&media=mobile [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^standard/(.*)$ standard.html?THISPAGE=$1&media=standard [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^print/(.*)$ print.html?THISPAGE=$1&media=print [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^pdf/(.*)$ pdf.html?THISPAGE=$1&media=pdf [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^proposal/(.*)$ proposal.html?THISPAGE=$1&media=proposal [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^flash/(.*)$ flash.html?THISPAGE=$1&media=flash [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^contrast/(.*)$ contrast.html?THISPAGE=$1&media=contrast [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?THISPAGE=$1 [L,QSA]
RewriteRule ^/site/aboutus/(.*)$ /$1 [L,R=301]
RewriteRule ^site/aboutus/ / [L,R=301]
RewriteRule ^pages/about_us.htm /about.html [L,R=301]
RewriteRule ^site/contact/ /contact.html [L,R=301]
RewriteRule ^site/library/ /resources.html [L,R=301]
RewriteRule ^site/services/ /services.html [L,R=301]
RewriteRule ^site/services/alternative_dispute_resolution/ /services/alternative-dispute-resolution.html [L,R=301]
RewriteRule ^site/services/business_visas/ /services/business-visas.html [L,R=301]
RewriteRule ^site/services/civil_comm_litigation/ /services/civil-commercial-litigation-copy.html [L,R=301]
RewriteRule ^site/services/clinical_negligence/ /services/clinical-negligence.html [L,R=301]
RewriteRule ^site/services/conveyancing/commercial/ /services/commercial-conveyancing.html [L,R=301]
RewriteRule ^site/services/company_law/ /services/company-law.html [L,R=301]
RewriteRule ^site/services/criminal_law/ /services/criminal-law.html [L,R=301]
RewriteRule ^site/services/divorce_matrimonial/ /services/divorce-matrimonial.html [L,R=301]
RewriteRule ^site/services/employment_law/ /services/employment-law.html [L,R=301]
RewriteRule ^site/services/human_rights/ /services/human-rights-issues.html [L,R=301]
RewriteRule ^site/services/immigration/ /services/immigration.html [L,R=301]
RewriteRule ^site/services/leases_tenancy/ /services/leases-tenancy-agreements.html [L,R=301]
RewriteRule ^site/services/injury_medical_negligence/ /services/personal-injury-medical-negligence.html [L,R=301]
RewriteRule ^site/services/pro_bono/ /services/pro-bono.html [L,R=301]
RewriteRule ^site/services/conveyancing/ /services/residential-conveyancing.html [L,R=301]
RewriteRule ^site/services/conveyancing/residential/ /services/residential-conveyancing.html [L,R=301]
RewriteRule ^site/services/wills_trusts_probates/ /services/wills-trusts-probates.html [L,R=301]
RewriteRule ^site/people/ /team.html [L,R=301]
</IfModule>
It's because you have this rule before all of your other services redirect rules:
RewriteRule ^site/services/ /services.html [L,R=301]
This is saying, "anything that starts with /site/services/ gets redirected to /services.html". So, when you have a rule like:
RewriteRule ^site/services/company_law/ /services/company-law.html [L,R=301]
after it, the second rule will never get executed, since the second rule matches /site/services/company_law, which starts with /site/services/, thus matching the first rule. You need to re-order all of your rules so that the more general rule is at the end. Just put the
RewriteRule ^site/services/ /services.html [L,R=301]
rule at the very bottom.

i do not want to redirect some page, my code is

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . content.php [L]
RewriteRule !((inquiry|gallery)|(.*)\.(jpg|png|JPG|PNG|gif)$) content.php?q=$1 [L,QSA]
I am trying but it shown page not found
Try reversing the rules:
RewriteEngine on
RewriteRule !((inquiry|gallery)|(.*)\.(jpg|png|JPG|PNG|gif)$) content.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . content.php [L]

Resources