Htaccess file edit subfolder redirect main page - html

My code is under http://domainname/senoglu
But I want to see www.domainname.com but main page is http://domainname/senoglu
I don't have access top directory
I can do with htaccess file
But its coming 3 subdirector
Bodrum
istanbul
senoglu
Myweb page code is under senoglu/.
Istanbul subdomain like istanbul.domainname.com

Try this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domainname.com$
RewriteCond %{REQUEST_URI} !^/senoglu/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /senoglu/$1
RewriteCond %{HTTP_HOST} ^(www.)?domainname.com$
RewriteRule ^(/)?$ senoglu/index.html [L]
Tell me how it goes!

Related

How do I remove the .html from the end of URL while using SiteGround

I had originally built my website in React before learning that my client is using SiteGround so I had to change everything over to a basic HTML format. I have my navbar using href = "fileName.html" to navigate the page. This leads the URL to become www."siteName".com/"fileName.html" once navigating off the homepage.
This is what I have so far in my .htaccess to remove the .html from the end:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (.*) $1.html [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
This does not seem to be working. Should I change my .htaccess file? Should I change the way my navbar navigates the pages?
With your shown samples/attempts, please try following .htaccess Rules file. Please make sure to clear your browser cache before testing your URLs.
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine ON
RewriteBase /
###Rules for handling .html to without html uri in browser.
RewriteCond %{REQUEST_URI} \s/([^.]*)\.html\s [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/$1\.html -f [NC]
RewriteRule ^(.*)/?$ $1.html [L]
##Rule from OP's already existing .htaccess file.
RewriteRule ^index\.html$ - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>

Redirect deleted images url to home page in .htaccess file

I have deleted some images from my website but for SEO purposes I want to redirect those image path(URL) to my homepage. I have put this code in my .htaccess file but it is not working.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d # not a dir
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^.*\.(.jpg|.jpeg|.png|.gif)$ https://www.homepage.com/ [L,R=301]
Your regex pattern has extra dots.
You may try this rule:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(jpe?g|png|gif)$ / [L,R=301,NC]

Remove .html off URL. .htaccess

I'm building a site in a Node.js container, and the .htaccess is not working. I just want to remove the .html off the url, but the following just downloads the pages as files. Sorry if this has been answered, just need help. Thanks!
What we currently have:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
To remove .html all you need to use is:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
EDIT:
Some hosting services require a slightly different layout:
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

.htaccess - hide folder and .html

My folder structure looks like this:
domain.com/html/page.html .
If I click on a link on the page I want the URL to look like this: domain.com/page .
I tried out different .htaccess snippets but nothing worked the way I want. At the moment you can visit domain.com/html/page and you see the right page, but if you click on a link the URL is domain.com/html/page.html .
My .htaccess:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /$1.html [QSA,L]
I hope, someone can help me, thanks in advance!
You can put this code in your htaccess
Options -MultiViews
RewriteEngine On
RewriteBase /
# Redirect /html/some-page.html to /some-page
RewriteCond %{THE_REQUEST} \s/html/([^/]+)\.html\s [NC]
RewriteRule ^ %1 [R=301,L]
# Rewrite /some-page to /html/some-page.html if it exists
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/html/$1\.html -f
RewriteRule ^([^/]+)$ html/$1.html [L]

Point image request to a higher folder thru htaccess

Is there any rule I can write to make all requests to my image folder point up one folder. I'm dealing with a lot of links so I don't want to put ../
Eg: http://hostingxtreme.com/ajax/images/logo.png.
Should become http://hostingxtreme.com/images/logo.png
Thanks
Here the code I'm using
Dosent seem to be working!
php_value register_long_arrays On
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteEngine On
RewriteRule ^/?ajax/images/logo.png$ /images/logo.png [L,R=301]
</IfModule>
In the htaccess file in your document root, add either:
Redirect 301 /ajax/images/logo.png /images/logo.png
Or if you need to use mod_rewrite:
RewriteEngine On
RewriteRule ^/?ajax/images/logo.png$ /images/logo.png [L,R=301]
I got it!
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (ajax/|ajax/.*/)images/(.*)
RewriteRule (ajax/|ajax/.*/)images/(.*) images/$2
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (ajax/|ajax/.*/)stylesheets/(.*)
RewriteRule (ajax/|ajax/.*/)stylesheets/(.*) stylesheets/$2