Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8470511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:32:21+00:00 2026-06-10T16:32:21+00:00

Possible Duplicate: htaccess rewrite breaks relative paths I am hoping someone can help me.

  • 0

Possible Duplicate:
htaccess rewrite breaks relative paths

I am hoping someone can help me. I am trying to set my website to use pretty URLs.

I currently have a few htaccess commands which hide my subdomain folder containing all my php files as well as a command to change my protocol from http to https and vice versa. The pretty url is proving to be difficult. I want to do it solely by htaccess and not php. I managed to write a command which worked but non of my css or javascript worked after that.

# Redirect from website.com to www.website.com
RewriteCond %{HTTP_HOST} ^website.com [NC]
RewriteCond %{HTTP_HOST} !^www [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# redirect url to www
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /defaultfolder/([^\ ]+)\ HTTP/
RewriteRule ^(.*)$ defaultfolder/error.php [L]

#this section hides the defaultfolder, tried to modify this code here to make friendly urls.
RewriteCond %{HTTP_HOST} www.website.com
RewriteCond %{REQUEST_URI} !defaultfolder/
RewriteCond %{REQUEST_URI} !images/
RewriteRule ^(.*)\/$ defaultfolder/$1\.php [L]

#https redirect
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} (/defaultfolder/)(login|securepages|pages)\.php
RewriteRule ^defaultfolder/(.*)$ https://www.website.com/$1 [R,L]

#http redirect
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} (/defaultfolder/)(index|nonsecure pages)\.php
RewriteRule  ^defaultfolder/(.*)$ http://www.website.com/$1 [R,L]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T16:32:23+00:00Added an answer on June 10, 2026 at 4:32 pm

    non of my css or javascript worked after that.

    This is probably a relative/absolute path issue. When you change the path of the URL, relative links are going to break because the base has changed. You can either add a couple of rules to point requests for css/js to the right places, or try adding the correct base using the <base> tag in the header of your pages. Something like:

    <base href="/">
    

    Otherwise you may have to rewrite the way css and js get resolved. Say for instance, you have all of your styles in /css/ and all your scripts in /js/:

    RewriteCond %{REQUEST_URI} !^/css/
    RewriteRule ^(.*\.css)$ /css/$1 [L]
    
    RewriteCond %{REQUEST_URI} !^/js/
    RewriteRule ^(.*\.js)$ /js/$1 [L]
    

    <head><link rel="stylesheet" type="text/css" href="css/main.css" media="all"/>
    

    and this is in the main subfolder

    So that would mean you need a rule like this:

    RewriteCond %{REQUEST_URI} !/defaultfolder/
    RewriteRule ^(css|js)/(.*)\.(css|js)$ defaultfolder/%1/%2.%3 [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: .htaccess rewrite image file to php script How can I execute a
Possible Duplicate: Redirect *.htm to *.php htaccess rewrite if redirected file exists I set
Possible Duplicate: Access GET variables with PHP + .htaccess I am trying write a
Possible Duplicate: How to use .htaccess in WAMP Server? I'm using Wamp Server 2.0
Possible Duplicate: Remove .php extension with .htaccess I'm trying to hide the .php file
Possible Duplicate: .htaccess RewriteRule for Flat Links i have a problem in a rewrite
Possible Duplicate: mod_rewrite - how to rewrite an URL? Hi can anyone of you
Possible Duplicate: Query Strings & Mod ReWrite I have written a .htaccess file which
Possible Duplicate: How to add .php extension using .htaccess url rewriting? I want to
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.