Hi friends,

i want to redirection script for

www.xxxx.com/abc/ to www.xxxx.com/

my website saved in abc folder. first i set the permenent redirection in Cpanel from xxx.com to xxx.com/abc. but i want to display onley website name..dont want to display folder.

Now, i am using this code.. but not working...

RewriteRule ^abc/$ / [R=302]

Please suggest that..

Dani AI

Generated

wanted the site that lives in the abc folder to appear at the root URL without showing /abc. Two practical options were suggested in the thread; here is a concise, safe summary and what to try next.

If you control the server (or have WHM/root), the cleanest fix is to point the virtual host’s document root at the abc directory so requests for / load files from that folder. This avoids rewrites entirely and is the simplest for apps that generate absolute URLs. As noted, this requires changing the Apache virtual host settings (or the account DocumentRoot) and is the preferred approach when possible.

If you cannot change the server config (shared hosting with only cPanel), use an internal rewrite in the parent document root so the URL stays as / while Apache serves content from /abc. This is an internal rewrite, not a redirect, so browsers keep the domain-only address. As hinted, do an internal rewrite rather than an external redirect.

Example .htaccess (place in the site’s public document root, parent of abc):

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/abc/
RewriteRule ^(.*)$ /abc/$1 [L]

Notes and troubleshooting:

  • If the application outputs absolute links that include /abc, update the app’s base/URL settings or move files; rewrites do not change URLs the app generates.
  • Put the .htaccess in the correct folder and ensure mod_rewrite and AllowOverride are enabled.
  • To debug, clear caches, check Apache error logs, and request a known resource (CSS/JS) to confirm paths resolve correctly.
  • If SEO or duplicate-content is a concern, use canonical tags and test both approaches to decide which fits the site.

Recommended Answers

All 2 Replies

Change [R=302] to just [L]

commented: I think this will work :) +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.