Broken links in a Drupal subdomain - .htaccess

Currently I have a site, https://mysite.com/ a working Drupal7 site. I want to have something like this, https://mysite.com/dev in order for me to test the things first on this location before finally uploading it to the main site. What I did was copy the entire folder where all the files located and pasted it inside /dev. I made a duplicate of the DB being used by the main site and edited the file settings.php under sites/default/, edited the base url from https://www.mysite.com/ to https://www.mysite.com/dev. But when I tried navigating the pages using the links(menu, admin) it gives me Page not found response. In addition, I did uncomment this line RewriteBase / on my .htaccess file. I can also log in, but after logging in the links point to the main site like this, https://mysite.com/link1, https://mysite.com/link2 and so on. What did I miss? Can someone please help? Thanks!

I think I finally got it working. I did mention I edited a single line on my .htaccess file which is the RewriteBase / and I did, I promise. I changed it to RewriteBase /dev but when I tested the site, the links still go to the main site as I have mentioned above. What I did was research more on editing .htaccess and somewhere down the road I got here. I lack a few lines of codes which will solve my dilemma, somewhere between RewriteCond and RewriteBase lines. I need to add these lines, RewriteCond %{REQUEST_URI} ^/dev
RewriteRule ^ dev/index.php [L]. After adding these two lines, I tested the site again and it worked like magic. That's it. Thank you guys.

Related

Put Kohana web page in server with other apps

I'm trying to install a Kohana web page in a server that has another applications and I'm getting the error 'No direct access allowed'.
When I try to go to index page I see the directory. I think that it has something to do with .htaccess file or SYSPATH, but i can't figure it out.
Someone can help me?
Thank you very much
Difficult to guess what the cause of your problem might be, but do you have a line that begins RewriteBase in your .htaccess?
If not try adding one before the RewriteRule .* index.php/$0 [PT] line, in the format:
RewriteBase /directory-name-here/
So if the directory your kohana application's in is named kohana, you want a line like:
RewriteBase /kohana/
SYSPATH is defined in index.php of Kohana framework.
so make sure your .htaccess is poining to correct index file.

How to change base_url in drupal 7, fail to find answer online

I am trying to change base_url on my drupal 7 website, but failed to do it and google a lot, still could not solve it .
I am running localhost/drupal "on my local server. but I want to run it like
" localhost ". ( sorry I have to get rid of http://, otherwise it doesnot let me post)
How to get rid of folder in the url. I know I need to change $base_url on sites/default/setting.php to
$base_url = 'localhost'; // NO trailing slash! ( sorry I have to get rid of http://, otherwise it doesnot let me post)
And in the .htaccess file I am so confused what should I change. People online have their own solution, some said they work , some could not . Could someone give me some suggesttion ?
I assume this has to do with where you have placed your files.
In your file system, remove the 'drupal' directory and place all the files within that at /var/www/html ... instead of /var/www/html/drupal, if that's how it is currently set up.
I feel your pain; I've had this trouble myself before and I believe I had to alter both the settings.php and the htaccess (but try one at a time to begin with). I'm fairly sure that the section below in your .htaccess is what needs changing (just remove the hash from in front of the RewriteBase line). If you're unsure of what you're doing, make a copy of your .htaccess as htaccess.txt and then you can always switch back over if things get nasty.
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
I just realised that what you need is a re-write rule in an .htaccess file within your root folder (not the one that's inside the drupal folder). First, undo any edits you've already made, then create an .htaccess file in the same folder that contains your drupal folder and in it, add:
RewriteEngine On
RewriteRule ^$ /drupal [L]
That should send any traffic from the root into the drupal file structure. If you get issues with strange css, or urls that include the /drupal path, you'll need to revisit the other options in the /drupal/.htaccess file and your settings.php file in order to get it all working correctly.
However, going down this route, you may as well just copy all the files and folders into the root directory anyway (as the first answer suggested), assuming you're not going to be running multiple sites. If you do want to be testing multiple sites, you can just change the RewriteRul above to whatever site directory you're wanting to test in future.

How to perform htaccess rewrite

Here is the summary of my problem.
I have created a Facebook like button. It works correctly most of the time, however not when following the link from somebody's actual "like" post. It seems that Facebook is adding some more info to the URL. For instance, I have
www.example.com/blog.php/6
but Facebook adds
www.example.com/blog.php/6?fb_action_ids=10201090685057512&fb_action_types=og.likes&fb_source=aggregation&fb_aggregation_id=288381481237582
When a user follows this link they get a Mysql syntax error. If they follow the first link there is no problem. I thought I could just strip off all that extra text from the URL.
I created a .htaccess file and placed it in my root directory on GoDaddy.
I Tried several different rewrites.
Nothing has worked. This is the latest thought I tried:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*&)?fb_action_ids=
RewriteRule ^(.*)$ $1?%1 [R=301]
Do I need to change my .htaccess file or is there another way to solve this problem?
Thanks for the help.

.htaccess - How to hide the internal directory used by subdomains?

I installed a small FTP space for my classmates which allows them to upload school related documents to my server. After the files have been uploaded, they can be easily accessed via a subdomain i.e. ftp.mydomain.com
Everything is working fine, the files can be downloaded and everything works properly.
There are two things which still annoy me though:
If you enter ftp.mydomain.com you see Index of /my_internal_directory instead of something like Index of /
Once you enter a sub-directory and click the Parent Directory link it will redirect you to ftp.mydomain.com/my_internal_directory/ as well
Is there any way to hide my_internal_directory ?
This is the content of my .htaccess file so far:
RewriteEngine on
RewriteCond %{HTTP_HOST} ftp\.mydomain\.com
RewriteCond %{REQUEST_URI} !^/my_internal_directory/
RewriteRule ^(.*)$ /my_internal_directory/$1 [L]
Any help would be greatly appreciated.
If you are using linux server then you can remove read permission for folder my_internal_directory
If not resolve, try to add:
Options -Indexes
on top of the file.
If still doesnt resolve please post your .htaccess file... :)

.htaccess not working in subfolder

I have a couple of sites that are currently under development and I've put them under a specific subfolder for clients/co-workers to view - "http://dev.staffanestberg.com/site-name/". I've run into some problems getting the sites working with .htaccess. I can reach the index page by typing in the url for a site folder but neither img/style/js/etc linking or page rewriting works. Looking for a solution to this, Apache's "RewriteBase" seems to be the most likely one, however I can't get it to work.
Tried
RewriteBase http://dev.staffanestberg.com/site-name/
RewriteBase /site-name
What would be the correct method?
Thanks in advance,
-Staffan
mod_rewrite’s RewriteBase directive does only apply to rewrites using RewriteRule. And that does only apply for requests that are sent to the server.
But if the requested URIs are already wrong, RewriteBase doesn’t do any help. What you could try instead is the HTML element BASE that set’s the base URI for the current document.

Resources