1

I've a htaccess that's working for something that's exist in root, like https://www.example.com but in this case i want to use this htaccess for a script that's copied to https://example.com/app

In this case we don't have www and also our scripts are copied to app directory.

My htaccess that's working in https://www.example.com exist in below of this paragraph:

RewriteEngine on

# Matching any of 3 domains without www, and no subdomain
RewriteCond %{HTTP_HOST} ^(example)\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^courses/([0-9]+)/?([0-9a-zA-Z_-]+)? index.php?p_post=$1&t=$2 [QSA]

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^category/(.*) index.php?category=$1 [NC,L]

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^search/(.*) index.php?search=$1 [NC,L]

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^tags/(.*) index.php?tags=$1 [NC,L]

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

Please help me to changing this codes for something like https://example.com/app

Thanks!

Notice: This htaccess is right and usable to use in sub directories and the problem was from my php script, after debug everything worked good.

1 Answer 1

1

create a new .htaccess file in subfolder and type

Options -Indexes

if don't want to index there content.

Sign up to request clarification or add additional context in comments.

4 Comments

The index page loaded but It's not working for posts, categories, search and tags and i have 404 Not Found error, when i want to open a link like example.com/app/courses/1/open-source-programming
look like permission error can you please tell me which server and os your are using
os: Linux , WebServer: LiteSpeed Web Server
The problem was in my script and solved after debug and I used my htaccess that's exist on here. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.